Aspose.Email for C++ का उपयोग करके ईमेल संदेश लोड और सेव करें
Aspose.Email for C++ लोड, सेव और कई फॉर्मैट में ईमेल संदेशों को कनवर्ट करने के लचीले विकल्प प्रदान करता है, जिसमें EML, MSG, MHTML, और HTML शामिल हैं। आप एन्कोडिंग, अटैचमेंट्स और फॉर्मैटिंग आवश्यकताओं को संभालने के लिए लोड और सेव विकल्पों को भी कस्टमाइज़ कर सकते हैं।
इस लेख में नमूने इन हेडर्स और नेमस्पेसेज़ का उपयोग करते हैं:
#include <MailMessage.h>
#include <EmlLoadOptions.h>
#include <EmlxLoadOptions.h>
#include <HtmlLoadOptions.h>
#include <MhtmlLoadOptions.h>
#include <MsgLoadOptions.h>
#include <TnefLoadOptions.h>
#include <SaveOptions.h>
#include <EmlSaveOptions.h>
#include <MsgSaveOptions.h>
#include <MhtSaveOptions.h>
#include <HtmlSaveOptions.h>
#include <MailMessageSaveType.h>
#include <MhtFormatOptions.h>
#include <HtmlFormatOptions.h>
#include <MhtTemplateName.h>
#include <system/collections/specialized/string_dictionary.h>
#include <ResourceRenderingMode.h>
#include <FileCompatibilityMode.h>
#include <AttachmentCollection.h>
#include <Attachment.h>
#include <Mapi/MapiMessage.h>
#include <Mapi/MapiConversionOptions.h>
#include <Mapi/OutlookMessageFormat.h>
#include <Tools/FileFormat/FileFormatUtil.h>
#include <Tools/FileFormat/FileFormatInfo.h>
#include <Tools/FileFormat/FileFormatType.h>
#include <system/io/file.h>
#include <system/io/directory.h>
#include <system/io/file_info.h>
#include <system/text/encoding.h>
#include <system/object_ext.h>
#include <system/convert.h>
#include <system/timezone_info.h>
#include <system/timespan.h>
using namespace System;
using namespace Aspose::Email;
using namespace Aspose::Email::Mapi;
using namespace Aspose::Email::Tools;
कस्टमाइज़्ड लोड विकल्पों के साथ संदेश लोड करें
यह MailMessage क्लास EML, EMLX, MSG, MHTML, HTML और TNEF रूप में संदेश लोड करता है। प्रत्येक इनपुट स्वरूप का अपना उत्तराधिकारी होता है LoadOptions, और ऑब्जेक्ट को पास किया जाता है MailMessage::Load फ़ाइल नाम या स्ट्रीम के साथ मिलकर। बेस क्लास सभी में तीन सेटिंग्स जोड़ता है - PreferredTextEncoding एक घोषित चरसेट के बिना टेक्स्ट के लिए, PreserveEmbeddedMessageFormat संदेशों के रूप में संलग्न वस्तुओं के लिए, और RemoveSignature - जबकि प्रत्येक प्रारूप अपने स्वयं का जोड़ता है:
| वर्ग | प्रारूप | अतिरिक्त सेटिंग्स | | — | — | — | | EmlLoadOptions | EML | PreserveTnefAttachments |
| EmlxLoadOptions | EMLX (Apple Mail) | - | | HtmlLoadOptions | HTML | PathToResources, ShouldAddPlainTextView |
| MhtmlLoadOptions | MHTML | PreserveTnefAttachments |
| MsgLoadOptions | Outlook MSG | KeepOriginalEmailAddresses, PreserveRtfContent, PreserveTnefAttachments, टाइमआउट |
| TnefLoadOptions | raw TNEF (winmail.dat) | - |
// EML
SharedPtr<EmlLoadOptions> emlOptions = MakeObject<EmlLoadOptions>();
emlOptions->set_PreferredTextEncoding(System::Text::Encoding::get_UTF8()); // encoding for subject and body
emlOptions->set_PreserveEmbeddedMessageFormat(true); // keep embedded items as they are
emlOptions->set_PreserveTnefAttachments(true); // keep winmail.dat parts
emlOptions->set_RemoveSignature(false); // keep the S/MIME signature
SharedPtr<MailMessage> eml = MailMessage::Load(u"sample.eml", emlOptions);
// EMLX (Apple Mail)
SharedPtr<EmlxLoadOptions> emlxOptions = MakeObject<EmlxLoadOptions>();
emlxOptions->set_PreferredTextEncoding(System::Text::Encoding::get_UTF8());
emlxOptions->set_PreserveEmbeddedMessageFormat(true);
SharedPtr<MailMessage> emlx = MailMessage::Load(u"sample.emlx", emlxOptions);
// HTML
SharedPtr<HtmlLoadOptions> htmlOptions = MakeObject<HtmlLoadOptions>();
htmlOptions->set_PathToResources(u"."); // where the referenced images live
htmlOptions->set_ShouldAddPlainTextView(true); // add a text/plain alternative
SharedPtr<MailMessage> fromHtml = MailMessage::Load(u"body_content.html", htmlOptions);
// MHTML
SharedPtr<MhtmlLoadOptions> mhtmlOptions = MakeObject<MhtmlLoadOptions>();
mhtmlOptions->set_PreserveTnefAttachments(true);
SharedPtr<MailMessage> fromMhtml = MailMessage::Load(u"sample.mhtml", mhtmlOptions);
// MSG
SharedPtr<MsgLoadOptions> msgOptions = MakeObject<MsgLoadOptions>();
msgOptions->set_KeepOriginalEmailAddresses(true); // do not rewrite Exchange addresses
msgOptions->set_PreserveRtfContent(true); // keep the RTF body
msgOptions->set_Timeout(5000); // formatting time limit, milliseconds
SharedPtr<MailMessage> fromMsg = MailMessage::Load(u"sample.msg", msgOptions);
// TNEF - a raw winmail.dat file, not a message that contains one
SharedPtr<TnefLoadOptions> tnefOptions = MakeObject<TnefLoadOptions>();
tnefOptions->set_PreferredTextEncoding(System::Text::Encoding::get_UTF8());
SharedPtr<MailMessage> fromTnef = MailMessage::Load(u"winmail.dat", tnefOptions);
Console::WriteLine(u"Subjects: " + eml->get_Subject() + u" | " + emlx->get_Subject() +
u" | " + fromMsg->get_Subject() + u" | " + fromTnef->get_Subject());
winmail.dat फ़ाइल। एक सामान्य संदेश जो केवल ऐसा संलग्नक ले जाता है, उसे अपने स्वरूप के विकल्पों के साथ लोड किया जाता है, जैसा कि इसमें दिखाया गया है TNEF अटैचमेंट्स के साथ काम करना.
संलग्न संदेश के स्वरूप को संरक्षित रखें
एक वस्तु जो संदेश के रूप में संलग्न है, MSG या EML के रूप में संग्रहीत की जा सकती है। साथ में PreserveEmbeddedMessageFormat संलग्नक स्रोत फ़ाइल में जिस स्वरूप में था, वही रखता है बदलने के बजाय:
SharedPtr<EmlLoadOptions> options = MakeObject<EmlLoadOptions>();
options->set_PreserveEmbeddedMessageFormat(true);
SharedPtr<MailMessage> mail = MailMessage::Load(u"tnefWithMsgInside.eml", options);
// the embedded item keeps the format it had in the source message
FileFormatType fileFormat = FileFormatUtil::DetectFileFormat(
mail->get_Attachments()->idx_get(0)->get_ContentStream())->get_FileFormatType();
Console::WriteLine(u"Embedded message file format: " + ObjectExt::ToString(fileFormat));
हस्ताक्षरित संदेश और फ़ाइल स्वरूप पहचान
एक हस्ताक्षर रखा जाता है जबकि संदेश पार्स किया जाता है। RemoveSignature लाइब्रेरी को इसे छोड़ने को कहता है, और FileFormatUtil::DetectFileFormat फ़ाइल वास्तव में क्या है, इसे लोड होने से पहले रिपोर्ट करता है - उपयोगी जब एक्सटेंशन भरोसेमंद नहीं हो।
// a signature is kept by default
SharedPtr<MailMessage> signedMessage = MailMessage::Load(u"signed.eml");
Console::WriteLine(u"IsSigned: " + Convert::ToString(signedMessage->get_IsSigned()) +
u", IsEncrypted: " + Convert::ToString(signedMessage->get_IsEncrypted()));
// RemoveSignature strips it while the message is parsed
SharedPtr<EmlLoadOptions> options = MakeObject<EmlLoadOptions>();
options->set_RemoveSignature(true);
SharedPtr<MailMessage> unsigned_ = MailMessage::Load(u"signed.eml", options);
Console::WriteLine(u"After RemoveSignature: " + Convert::ToString(unsigned_->get_IsSigned()));
// the format of a file can be detected before it is loaded
SharedPtr<FileFormatInfo> info = FileFormatUtil::DetectFileFormat(u"Message.msg");
Console::WriteLine(u"The message format is: " + ObjectExt::ToString(info->get_FileFormatType()));
विभिन्न फॉर्मैट में ईमेल संदेश सहेजें
Aspose.Email for C++ EML, MSG, MHTML, और HTML जैसी फॉर्मैट के बीच संदेशों के रूपांतरण को सक्षम बनाता है। डेवलपर्स इसका उपयोग कर सकते हैं SaveOptions क्लास हाइरार्की उन्नत सेव पैरामीटर निर्धारित करने के लिए, जिसमें एन्कोडिंग, TNEF अटैचमेंट्स और बाउंड्री प्रिज़र्वेशन शामिल हैं।
उपलब्ध सेव विकल्पों में शामिल हैं:
EmlSaveOptionsMsgSaveOptionsMhtSaveOptionsHtmlSaveOptions
ईमेल को EML के रूप में सेव करें
MailMessage::Save के साथ SaveOptions::get_DefaultEml संदेश को EML फ़ाइल के रूप में लिखता है। उदाहरण एक EML संदेश लोड करता है और वही स्वरूप में वापस सहेजता है।
SharedPtr<MailMessage> mailMessage = MailMessage::Load(u"Attachments.eml");
mailMessage->Save(u"Attachments_copy.eml", SaveOptions::get_DefaultEml());
Console::WriteLine(u"Attachments in the copy: " + Convert::ToString(MailMessage::Load(u"Attachments_copy.eml")->get_Attachments()->get_Count()));
मूल EML बाउंड्रीज़ को संरक्षित रखें
MIME सीमाएं संदेश के भागों को अलग करती हैं। जब एक EML संदेश लोड किया जाता है और फिर EML के रूप में सहेजा जाता है, तो स्रोत की सीमाएं रखी जाती हैं, इसलिए सहेजी फ़ाइल को मूल के भाग‑दर‑भाग तुलना की जा सकती है; इसके लिए कोई विकल्प आवश्यक नहीं। अपनी स्वयं की सीमाएं एक टेम्प्लेट के साथ सेट की जा सकती हैं, जैसा कि दिखाया गया है MIME सीमाओं को अनुकूलित करें.
SharedPtr<MailMessage> mailMessage = MailMessage::Load(u"Attachments.eml");
SharedPtr<EmlSaveOptions> emlSaveOptions = MakeObject<EmlSaveOptions>(MailMessageSaveType::get_EmlFormat());
mailMessage->Save(u"PreservedBoundaries.eml", emlSaveOptions);
// the first boundary of the source file and of the saved file
auto firstBoundary = [](String path)
{
String text = IO::File::ReadAllText(path);
int32_t start = text.IndexOf(u"boundary=\"") + 10;
return text.Substring(start, text.IndexOf(u'"', start) - start);
};
Console::WriteLine(u"Source: " + firstBoundary(u"Attachments.eml"));
Console::WriteLine(u"Saved: " + firstBoundary(u"PreservedBoundaries.eml"));
EML में TNEF अटैचमेंट्स को संरक्षित रखें
एक संदेश जिसमें TNEF भाग था (winmail.dat) सामान्यतः सादे MIME में पुनर्लेखित किया जाता है जब इसे सहेजा जाता है। सेटिंग FileCompatibilityMode::PreserveTnefAttachments पर EmlSaveOptions TNEF भाग को जैसा है वैसा रखता है, ताकि उस पर निर्भर क्लाइंट - विशेषकर Outlook - अभी भी अपना डेटा पाए। TNEF संदेशों के बारे में अधिक यहाँ है TNEF अटैचमेंट्स के साथ काम करना.
SharedPtr<MailMessage> mailMessage = MailMessage::Load(u"tnefEml1.eml");
SharedPtr<EmlSaveOptions> emlSaveOptions = MakeObject<EmlSaveOptions>(MailMessageSaveType::get_EmlFormat());
emlSaveOptions->set_FileCompatibilityMode(FileCompatibilityMode::PreserveTnefAttachments);
mailMessage->Save(u"PreservedTnef.eml", emlSaveOptions);
// the TNEF part is still there
SharedPtr<EmlLoadOptions> loadOptions = MakeObject<EmlLoadOptions>();
loadOptions->set_PreserveTnefAttachments(true);
for (SharedPtr<Attachment> attachment : MailMessage::Load(u"PreservedTnef.eml", loadOptions)->get_Attachments())
{
Console::WriteLine(attachment->get_Name() + u" - TNEF: " + Convert::ToString(attachment->get_IsTnef()));
}
EML को MSG में परिवर्तित करें
EML फ़ाइल Outlook MSG फ़ाइल बन जाती है जब इसे सहेजा जाता है साथ में SaveOptions::get_DefaultMsgUnicode - वर्तमान Outlook संस्करणों द्वारा उपयोग किया जाने वाला Unicode MSG स्वरूप - या साथ में get_DefaultMsg पुराने ANSI संस्करण के लिए।
SharedPtr<MailMessage> eml = MailMessage::Load(u"Message.eml");
eml->Save(u"FromEml.msg", SaveOptions::get_DefaultMsgUnicode());
Console::WriteLine(u"Saved as MSG: " + MapiMessage::Load(u"FromEml.msg")->get_Subject());
MHTML के रूप में सेव करें
SaveOptions::get_DefaultMhtml एकल MHTML फ़ाइल उत्पन्न करता है जिसे ब्राउज़र दिखा सकता है, संदेश हेडर बॉडी के ऊपर लिखा हुआ और छवियां एम्बेडेड।
SharedPtr<MailMessage> eml = MailMessage::Load(u"Message.eml");
eml->Save(u"FromEml.mhtml", SaveOptions::get_DefaultMhtml());
कस्टम टाइम ज़ोन के साथ MHT में एक्सपोर्ट करें
MHTML पृष्ठ के हेडर में लिखी तिथियां उसी समय क्षेत्र में प्रदर्शित होती हैं जो दिया गया है TimeZoneOffset. इसे स्थानीय सिस्टम के ऑफ़सेट पर सेट करें ताकि स्थानीय समय दिखे, या किसी भी स्थिर ऑफ़सेट पर; MhtFormatOptions::WriteHeader हेडर जिसमें तिथि है उसे लिखा जाना सुनिश्चित करता है।
SharedPtr<MailMessage> eml = MailMessage::Load(u"Message.eml");
// the offset of the local system ...
eml->set_TimeZoneOffset(TimeZoneInfo::get_Local()->GetUtcOffset(DateTime::get_Now()));
// ... or any fixed offset, here UTC-08:00
eml->set_TimeZoneOffset(TimeSpan(-8, 0, 0));
SharedPtr<MhtSaveOptions> options = MakeObject<MhtSaveOptions>();
options->set_MhtFormatOptions(MhtFormatOptions::WriteHeader);
eml->Save(u"CustomTimeZone.mhtml", options);
ईमेल को EML में एक्सपोर्ट करें
अन्य स्वरूपों से लोड किए गए संदेश EML में उसी तरह निर्यात होते हैं। उदाहरण Outlook MSG फ़ाइल को परिवर्तित करता है।
SharedPtr<MailMessage> msg = MailMessage::Load(u"Message.msg");
msg->Save(u"ExportedFromMsg.eml", SaveOptions::get_DefaultEml());
Console::WriteLine(u"Exported: " + MailMessage::Load(u"ExportedFromMsg.eml")->get_Subject());
MIME बाउंड्रीज़ को अनुकूलित करें
जब EML फ़ाइल लोड की जाती है और वापस सहेजी जाती है, तो स्रोत संदेश की सीमाओं को संरक्षित किया जाता है। इसके बजाय अपना पैटर्न बनाना चाहते हैं, तो सेट करें BoundariesTemplate पर EmlSaveOptions. दो स्थानधारकों का समर्थन किया जाता है: {#} सीमा संख्या के लिए और {guid} एक उत्पन्न GUID के लिए।
SharedPtr<MailMessage> mailMessage = MailMessage::Load(u"Attachments.eml");
SharedPtr<EmlSaveOptions> emlSaveOptions = MakeObject<EmlSaveOptions>(MailMessageSaveType::get_EmlFormat());
// {#} is replaced with the boundary number, {guid} with a generated GUID
emlSaveOptions->set_BoundariesTemplate(u"boundary_{#}_{guid}");
mailMessage->Save(u"CustomBoundaries.eml", emlSaveOptions);
Console::WriteLine(IO::File::ReadAllText(u"CustomBoundaries.eml").Substring(0, 300));
जब लक्ष्य स्वरूप MHTML हो, तो स्रोत संदेश की सीमाओं को रखा जाता है साथ में MhtSaveOptions::PreserveOriginalBoundaries.
मूल तिथियों को संरक्षित करें और टेम्पलेट के रूप में सहेजें
डिफ़ॉल्ट रूप से MSG में रूपांतरण वर्तमान समय को स्टैम्प करता है। PreserveOriginalDates स्रोत संदेश की तिथियों को बरकरार रखता है। Outlook टेम्पलेट स्वरूप (.oft) का अपना तैयार विकल्प सेट है, SaveOptions::DefaultOft.
SharedPtr<MailMessage> eml = MailMessage::Load(u"Attachments.eml");
// keep the dates of the source message instead of stamping the current time
SharedPtr<MsgSaveOptions> msgSaveOptions = MakeObject<MsgSaveOptions>(MailMessageSaveType::get_OutlookMessageFormatUnicode());
msgSaveOptions->set_PreserveOriginalDates(true);
eml->Save(u"PreservedDates.msg", msgSaveOptions);
// an Outlook template (.oft) is written with the dedicated save type
eml->Save(u"AsTemplate.oft", SaveOptions::get_DefaultOft());
Console::WriteLine(u"msg: " + Convert::ToString(MakeObject<IO::FileInfo>(u"PreservedDates.msg")->get_Length()) +
u" bytes, oft: " + Convert::ToString(MakeObject<IO::FileInfo>(u"AsTemplate.oft")->get_Length()) + u" bytes");
MHTML आउटपुट विकल्प
MhtSaveOptions MHTML आउटपुट को आकार देता है। MhtFormatOptions एक फ़्लैग एन्यूमरेशन है जो तय करता है कि क्या रेंडर किया जाए: WriteHeader मुख्य भाग के ऊपर हेडर ब्लॉक लिखता है, RenderCalendarEvent एक मीटिंग के विवरण जोड़ता है, RenderVCardInfo संपर्क के उन, RenderTaskFields कार्य के उन, और WriteComplete...EmailAddress सदस्य पूर्ण पते मुद्रित करते हैं न कि प्रदर्शन नाम। व्यक्तिगत हेडर पंक्तियों का स्वरूप टेम्प्लेट के माध्यम से निर्धारित होता है जिसका नाम है MhtTemplateName.
SharedPtr<MailMessage> msg = MailMessage::Load(u"Meeting_with_Recurring_Occurrences.msg");
// render the calendar event together with the header block
SharedPtr<MhtSaveOptions> options = MakeObject<MhtSaveOptions>();
options->set_MhtFormatOptions(MhtFormatOptions::WriteHeader | MhtFormatOptions::RenderCalendarEvent);
// the header lines can be reformatted through their templates
options->get_FormatTemplates()->idx_set(MhtTemplateName::Start,
u"<span class='headerLineTitle'>Start:</span><span class='headerLineText'>{0}</span><br/>");
msg->Save(u"MeetingWithEvent.mhtml", options);
// leave the inline images out of the output
SharedPtr<MhtSaveOptions> withoutImages = MakeObject<MhtSaveOptions>();
withoutImages->set_SkipInlineImages(true);
SharedPtr<MailMessage> eml = MailMessage::Load(u"EmailWithAttachEmbedded.eml");
eml->Save(u"NoInlineImages.mhtml", withoutImages);
// keep the MIME boundaries of the source message
SharedPtr<MhtSaveOptions> keepBoundaries = MakeObject<MhtSaveOptions>();
keepBoundaries->set_PreserveOriginalBoundaries(true);
eml->Save(u"OriginalBoundaries.mhtml", keepBoundaries);
आउटपुट के फ़ॉन्ट समायोजित करें
CSS ब्लॉक जो लाइब्रेरी MHTML में लिखती है, उपलब्ध है रूप में CssStyles स्ट्रिंग और सहेजने से पहले विस्तारित की जा सकती है:
SharedPtr<MailMessage> eml = MailMessage::Load(u"Attachments.eml");
SharedPtr<MhtSaveOptions> options = SaveOptions::get_DefaultMhtml();
// the CSS block that Aspose.Email writes into the MHTML can be extended
int32_t cssInsertPos = options->get_CssStyles().LastIndexOf(u"</style>");
options->set_CssStyles(options->get_CssStyles().Insert(cssInsertPos, u".PlainText{ font-family: sans-serif; }"));
eml->Save(u"CustomFont.mhtml", options);
संसाधनों को HTML में लिखने के तरीके को नियंत्रण करें
जब कोई संदेश HTML में निर्यात किया जाता है, उसके इनलाइन छवियां डिफ़ॉल्ट रूप से base64 डेटा के रूप में एम्बेड की जाती हैं। ResourceRenderingMode वह बदलता है: SaveToFile प्रत्येक संसाधन को HTML फ़ाइल के बगल में एक फ़ोल्डर में लिखता है और पथ को डालता है src गुणधर्म, SubstituteFromFile संसाधन को आपके अपने आइकन से बदलता है, और None संसाधनों को पूरी तरह से छोड़ देता है। PathToHtmlFile लाइब्रेरी को बताता है कि वह फ़ोल्डर कहां स्थित है, और UseRelativePathToResources मार्कअप में सापेक्ष पथ लिखता है।
SharedPtr<MailMessage> msg = MailMessage::Load(u"EmailWithAttachEmbedded.eml");
SharedPtr<HtmlSaveOptions> options = MakeObject<HtmlSaveOptions>();
// write the inline images next to the HTML file instead of embedding them as base64
options->set_ResourceRenderingMode(ResourceRenderingMode::SaveToFile);
options->set_PathToHtmlFile(u"HtmlExport.html");
options->set_UseRelativePathToResources(true);
// include the header block in the body
options->set_HtmlFormatOptions(HtmlFormatOptions::WriteHeader);
msg->Save(u"HtmlExport.html", options);
for (String f : IO::Directory::GetFiles(u".", u"HtmlExport*"))
{
Console::WriteLine(IO::Path::GetFileName(f));
}
MailMessage को MapiMessage में परिवर्तित करें
PST और OLM स्टोरेज, तथा Outlook स्वयं, MAPI वस्तुओं के साथ काम करते हैं। MapiMessage::FromMailMessage रूपांतरण करता है, और MapiConversionOptions इसके विवरण को नियंत्रित करता है:
| प्रॉपर्टी | अर्थ | | — | — | | Format | OutlookMessageFormat Unicode या Ascii. |
| PreserveOriginalDates | स्रोत संदेश की तिथियों को रखें। | | PreserveOriginalAddresses | पते को एक्सचेंज स्वरूप में पुनर्लेखन न करें। | | PreserveEmbeddedMessageFormat | संलग्न संदेशों को उनके अपने स्वरूप में रखें। | | UseBodyCompression | RTF बॉडी को संपीडित रूप में संग्रहीत करें। | | RemoveSignature | रूपांतरण के दौरान S/MIME हस्ताक्षर को हटाएँ। | | ForcedRtfBodyForAppointment | नियुक्तियों के लिए हमेशा RTF बॉडी लिखें। |
ASCIIFormat और UnicodeFormat दो Outlook स्वरूपों के लिए तैयार विकल्प सेट लौटता है।
SharedPtr<MailMessage> eml = MailMessage::Load(u"Attachments.eml");
SharedPtr<MapiConversionOptions> options = MakeObject<MapiConversionOptions>();
options->set_Format(OutlookMessageFormat::Unicode); // Unicode or Ascii
options->set_PreserveOriginalDates(true); // keep the dates of the source message
options->set_PreserveOriginalAddresses(true); // do not rewrite the addresses
options->set_PreserveEmbeddedMessageFormat(true); // keep embedded items in their own format
options->set_UseBodyCompression(true); // compress the RTF body
SharedPtr<MapiMessage> mapi = MapiMessage::FromMailMessage(eml, options);
mapi->Save(u"ConvertedWithOptions.msg");
// ready-made option sets for the two Outlook formats
SharedPtr<MapiMessage> unicode = MapiMessage::FromMailMessage(eml, MapiConversionOptions::get_UnicodeFormat());
SharedPtr<MapiMessage> ascii = MapiMessage::FromMailMessage(eml, MapiConversionOptions::get_ASCIIFormat());
Console::WriteLine(u"Unicode body: " + Convert::ToString(unicode->get_Body().get_Length()) +
u", ASCII body: " + Convert::ToString(ascii->get_Body().get_Length()));