ferencd@0: // ferencd@0: // VMime library (http://www.vmime.org) ferencd@0: // Copyright (C) 2002-2013 Vincent Richard ferencd@0: // ferencd@0: // This program is free software; you can redistribute it and/or ferencd@0: // modify it under the terms of the GNU General Public License as ferencd@0: // published by the Free Software Foundation; either version 3 of ferencd@0: // the License, or (at your option) any later version. ferencd@0: // ferencd@0: // This program is distributed in the hope that it will be useful, ferencd@0: // but WITHOUT ANY WARRANTY; without even the implied warranty of ferencd@0: // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ferencd@0: // General Public License for more details. ferencd@0: // ferencd@0: // You should have received a copy of the GNU General Public License along ferencd@0: // with this program; if not, write to the Free Software Foundation, Inc., ferencd@0: // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. ferencd@0: // ferencd@0: // Linking this library statically or dynamically with other modules is making ferencd@0: // a combined work based on this library. Thus, the terms and conditions of ferencd@0: // the GNU General Public License cover the whole combination. ferencd@0: // ferencd@0: ferencd@0: // ferencd@0: // EXAMPLE DESCRIPTION: ferencd@0: // ==================== ferencd@0: // This sample program demonstrate the use of the messageParser component ferencd@0: // to enumerate the attachments in a message. ferencd@0: // ferencd@0: // For more information, please visit: ferencd@0: // http://www.vmime.org/ ferencd@0: // ferencd@0: ferencd@0: #include ferencd@0: #include ferencd@0: #include ferencd@0: ferencd@0: #include "vmime/vmime.hpp" ferencd@0: #include "vmime/platforms/posix/posixHandler.hpp" ferencd@0: ferencd@0: ferencd@0: int main() ferencd@0: { ferencd@0: std::cout << std::endl; ferencd@0: ferencd@0: // Set the global C and C++ locale to the user-configured locale. ferencd@0: // The locale should use UTF-8 encoding for these tests to run successfully. ferencd@0: try ferencd@0: { ferencd@0: std::locale::global(std::locale("")); ferencd@0: } ferencd@0: catch (std::exception &) ferencd@0: { ferencd@0: std::setlocale(LC_ALL, ""); ferencd@0: } ferencd@0: ferencd@0: try ferencd@0: { ferencd@0: vmime::messageParser mp("<...MIME message content...>"); ferencd@0: ferencd@0: // Enumerate attachments ferencd@0: for (int i = 0 ; i < mp.getAttachmentCount() ; ++i) ferencd@0: { ferencd@0: const vmime::attachment& att = *mp.getAttachmentAt(i); ferencd@0: ferencd@0: // Media type (content type) is in "att.getType()" ferencd@0: // Name is in "att.getName()" ferencd@0: // Description is in "att.getDescription()" ferencd@0: // Data is in "att.getData()" ferencd@0: } ferencd@0: } ferencd@0: // VMime exception ferencd@0: catch (vmime::exception& e) ferencd@0: { ferencd@0: std::cout << "vmime::exception: " << e.what() << std::endl; ferencd@0: throw; ferencd@0: } ferencd@0: // Standard exception ferencd@0: catch (std::exception& e) ferencd@0: { ferencd@0: std::cout << "std::exception: " << e.what() << std::endl; ferencd@0: throw; ferencd@0: } ferencd@0: ferencd@0: std::cout << std::endl; ferencd@0: }