Last active
March 17, 2021 10:59
-
-
Save aspose-com-gists/a6d453aad8224a82727fc8c578fa3088 to your computer and use it in GitHub Desktop.
Convert Email MSG/EML to HTML using C++
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Convert Email MSG/EML to HTML using C++ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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