aboutsummaryrefslogtreecommitdiffstats
path: root/examples/example2.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'examples/example2.cpp')
-rw-r--r--examples/example2.cpp53
1 files changed, 27 insertions, 26 deletions
diff --git a/examples/example2.cpp b/examples/example2.cpp
index 67b8d844..da01d756 100644
--- a/examples/example2.cpp
+++ b/examples/example2.cpp
@@ -1,6 +1,6 @@
//
// VMime library (http://www.vmime.org)
-// Copyright (C) 2002-2013 Vincent Richard <[email protected]>
+// Copyright (C) 2002 Vincent Richard <[email protected]>
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
@@ -39,23 +39,20 @@
#include "vmime/platforms/posix/posixHandler.hpp"
-int main()
-{
+int main() {
+
std::cout << std::endl;
// Set the global C and C++ locale to the user-configured locale.
// The locale should use UTF-8 encoding for these tests to run successfully.
- try
- {
+ try {
std::locale::global(std::locale(""));
- }
- catch (std::exception &)
- {
+ } catch (std::exception &) {
std::setlocale(LC_ALL, "");
}
- try
- {
+ try {
+
vmime::messageBuilder mb;
// Fill in the basic fields
@@ -74,17 +71,20 @@ int main()
mb.setSubject(vmime::text("My first message generated with vmime::messageBuilder"));
// Message body
- mb.getTextPart()->setText(vmime::make_shared <vmime::stringContentHandler>(
- "I'm writing this short text to test message construction " \
- "with attachment, using the vmime::messageBuilder component."));
+ mb.getTextPart()->setText(
+ vmime::make_shared <vmime::stringContentHandler>(
+ "I'm writing this short text to test message construction " \
+ "with attachment, using the vmime::messageBuilder component."
+ )
+ );
// Adding an attachment
- vmime::shared_ptr <vmime::fileAttachment> a = vmime::make_shared <vmime::fileAttachment>
- (
- __FILE__, // full path to file
- vmime::mediaType("application/octet-stream"), // content type
- vmime::text("My first attachment") // description
- );
+ vmime::shared_ptr <vmime::fileAttachment> a =
+ vmime::make_shared <vmime::fileAttachment>(
+ __FILE__, // full path to file
+ vmime::mediaType("application/octet-stream"), // content type
+ vmime::text("My first attachment") // description
+ );
a->getFileInfo().setFilename("example2.cpp");
a->getFileInfo().setCreationDate(vmime::datetime("30 Apr 2003 14:30:00 +0200"));
@@ -101,20 +101,21 @@ int main()
std::cout << "==================" << std::endl;
std::cout << std::endl;
std::cout << dataToSend << std::endl;
- }
+
// VMime exception
- catch (vmime::exception& e)
- {
+ } catch (vmime::exception& e) {
+
std::cout << "vmime::exception: " << e.what() << std::endl;
throw;
- }
+
// Standard exception
- catch (std::exception& e)
- {
+ } catch (std::exception& e) {
+
std::cout << "std::exception: " << e.what() << std::endl;
throw;
}
std::cout << std::endl;
-}
+ return 0;
+}