Mercurial > thymian
comparison 3rdparty/vmime/examples/example5.cpp @ 0:a4671277546c tip
created the repository for the thymian project
| author | ferencd |
|---|---|
| date | Tue, 17 Aug 2021 11:19:54 +0200 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| -1:000000000000 | 0:a4671277546c |
|---|---|
| 1 // | |
| 2 // VMime library (http://www.vmime.org) | |
| 3 // Copyright (C) 2002-2013 Vincent Richard <vincent@vmime.org> | |
| 4 // | |
| 5 // This program is free software; you can redistribute it and/or | |
| 6 // modify it under the terms of the GNU General Public License as | |
| 7 // published by the Free Software Foundation; either version 3 of | |
| 8 // the License, or (at your option) any later version. | |
| 9 // | |
| 10 // This program is distributed in the hope that it will be useful, | |
| 11 // but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| 13 // General Public License for more details. | |
| 14 // | |
| 15 // You should have received a copy of the GNU General Public License along | |
| 16 // with this program; if not, write to the Free Software Foundation, Inc., | |
| 17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | |
| 18 // | |
| 19 // Linking this library statically or dynamically with other modules is making | |
| 20 // a combined work based on this library. Thus, the terms and conditions of | |
| 21 // the GNU General Public License cover the whole combination. | |
| 22 // | |
| 23 | |
| 24 // | |
| 25 // EXAMPLE DESCRIPTION: | |
| 26 // ==================== | |
| 27 // This sample program demonstrate the use of the messageParser component | |
| 28 // to enumerate the attachments in a message. | |
| 29 // | |
| 30 // For more information, please visit: | |
| 31 // http://www.vmime.org/ | |
| 32 // | |
| 33 | |
| 34 #include <iostream> | |
| 35 #include <locale> | |
| 36 #include <clocale> | |
| 37 | |
| 38 #include "vmime/vmime.hpp" | |
| 39 #include "vmime/platforms/posix/posixHandler.hpp" | |
| 40 | |
| 41 | |
| 42 int main() | |
| 43 { | |
| 44 std::cout << std::endl; | |
| 45 | |
| 46 // Set the global C and C++ locale to the user-configured locale. | |
| 47 // The locale should use UTF-8 encoding for these tests to run successfully. | |
| 48 try | |
| 49 { | |
| 50 std::locale::global(std::locale("")); | |
| 51 } | |
| 52 catch (std::exception &) | |
| 53 { | |
| 54 std::setlocale(LC_ALL, ""); | |
| 55 } | |
| 56 | |
| 57 try | |
| 58 { | |
| 59 vmime::messageParser mp("<...MIME message content...>"); | |
| 60 | |
| 61 // Enumerate attachments | |
| 62 for (int i = 0 ; i < mp.getAttachmentCount() ; ++i) | |
| 63 { | |
| 64 const vmime::attachment& att = *mp.getAttachmentAt(i); | |
| 65 | |
| 66 // Media type (content type) is in "att.getType()" | |
| 67 // Name is in "att.getName()" | |
| 68 // Description is in "att.getDescription()" | |
| 69 // Data is in "att.getData()" | |
| 70 } | |
| 71 } | |
| 72 // VMime exception | |
| 73 catch (vmime::exception& e) | |
| 74 { | |
| 75 std::cout << "vmime::exception: " << e.what() << std::endl; | |
| 76 throw; | |
| 77 } | |
| 78 // Standard exception | |
| 79 catch (std::exception& e) | |
| 80 { | |
| 81 std::cout << "std::exception: " << e.what() << std::endl; | |
| 82 throw; | |
| 83 } | |
| 84 | |
| 85 std::cout << std::endl; | |
| 86 } |
