Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@aspose-com-gists
Last active March 17, 2021 10:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aspose-com-gists/a6d453aad8224a82727fc8c578fa3088 to your computer and use it in GitHub Desktop.
Save aspose-com-gists/a6d453aad8224a82727fc8c578fa3088 to your computer and use it in GitHub Desktop.
Convert Email MSG/EML to HTML using C++
Convert Email MSG/EML to HTML using C++
// Load email file
System::SharedPtr<MailMessage> msg = MailMessage::Load(u"SourceDirectory\\Message.msg");
// Set the local time for message date.
msg->set_TimeZoneOffset(System::TimeZone::get_CurrentTimeZone()->GetUtcOffset(System::DateTime::get_Now()));
// Instantiate HtmlSaveOptions
System::SharedPtr<HtmlSaveOptions> saveOptions = System::MakeObject<HtmlSaveOptions>();
// Indicates that header information should be written.
saveOptions->set_HtmlFormatOptions(HtmlFormatOptions::WriteHeader);
// Convert email to HTML
msg->Save(u"OutputDirectory\\EmailToHTMLWithCustomTimezone.html", saveOptions);
// Load email file
System::SharedPtr<MailMessage> msg = MailMessage::Load(u"SourceDirectory\\Message.msg");
// Instantiate HtmlSaveOptions
System::SharedPtr<HtmlSaveOptions> saveOptions = System::MakeObject<HtmlSaveOptions>();
// Indicates that header information should be written.
saveOptions->set_HtmlFormatOptions(HtmlFormatOptions::WriteHeader);
// Convert email to HTML
msg->Save(u"OutputDirectory\\EmailToHTWithHeader.html", saveOptions);
// Load email file
System::SharedPtr<MailMessage> msg = MailMessage::Load(u"SourceDirectory\\Message.msg");
// Convert email to HTML
msg->Save(u"OutputDirectory\\EmailToHtml.html", Aspose::Email::SaveOptions::get_DefaultHtml());
// Load email file
System::SharedPtr<MailMessage> msg = MailMessage::Load(u"SourceDirectory\\Message.eml");
// Convert email to MHTML
msg->Save(u"OutputDirectory\\EmailToMhtml.mhtml", Aspose::Email::SaveOptions::get_DefaultMhtml());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment