From 681297e10b666e13cc463f6fbb16236f36c3266c Mon Sep 17 00:00:00 2001 From: Vincent Richard Date: Tue, 12 Jul 2005 22:28:02 +0000 Subject: Reference counting and smart pointers. --- examples/example2.cpp | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'examples/example2.cpp') diff --git a/examples/example2.cpp b/examples/example2.cpp index 70389076..ef4759aa 100644 --- a/examples/example2.cpp +++ b/examples/example2.cpp @@ -48,24 +48,24 @@ int main() mb.setExpeditor(vmime::mailbox("me@somewhere.com")); vmime::addressList to; - to.appendAddress(new vmime::mailbox("you@elsewhere.com")); + to.appendAddress(vmime::create ("you@elsewhere.com")); mb.setRecipients(to); vmime::addressList bcc; - bcc.appendAddress(new vmime::mailbox("you-bcc@nowhere.com")); + bcc.appendAddress(vmime::create ("you-bcc@nowhere.com")); mb.setBlindCopyRecipients(bcc); mb.setSubject(vmime::text("My first message generated with vmime::messageBuilder")); // Message body - mb.getTextPart()->setText(vmime::stringContentHandler( + mb.getTextPart()->setText(vmime::create ( "I'm writing this short text to test message construction " \ "with attachment, using the vmime::messageBuilder component.")); // Adding an attachment - vmime::fileAttachment* a = new vmime::fileAttachment + vmime::ref a = vmime::create ( "./example2.cpp", // full path to file vmime::mediaType("application/octet-stream"), // content type @@ -78,7 +78,7 @@ int main() mb.attach(a); // Construction - vmime::message* msg = mb.construct(); + vmime::ref msg = mb.construct(); // Raw text generation vmime::string dataToSend = msg->generate(); @@ -87,9 +87,6 @@ int main() std::cout << "==================" << std::endl; std::cout << std::endl; std::cout << dataToSend << std::endl; - - // Destruction - delete (msg); } // VMime exception catch (vmime::exception& e) -- cgit v1.2.3