Last active
April 27, 2021 11:59
-
-
Save aspose-com-gists/7496eada13a2a2eb4fff1d2e146dd91e to your computer and use it in GitHub Desktop.
Convert Email Messages to PDF 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 Messages to PDF 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
// Source email file | |
System::String sampleFile = u"SourceDirectory\\Message.msg"; | |
// Load email message using file | |
System::SharedPtr<Aspose::Email::MailMessage> msg = Aspose::Email::MailMessage::Load(sampleFile); | |
// Create memory stream | |
System::SharedPtr<System::IO::MemoryStream> stream = System::MakeObject<System::IO::MemoryStream>(); | |
// Save email message into memory stream | |
msg->Save(stream, Aspose::Email::SaveOptions::get_DefaultMhtml()); | |
// Create load options | |
System::SharedPtr<Aspose::Words::LoadOptions> loadOptions = System::MakeObject<Aspose::Words::LoadOptions>(); | |
// Set load format | |
loadOptions->set_LoadFormat(Aspose::Words::LoadFormat::Mhtml); | |
// Create an instance of Document class and load the MTHML from MemoryStream | |
System::SharedPtr<Aspose::Words::Document> doc = System::MakeObject<Aspose::Words::Document>(stream, loadOptions); | |
// Output file path | |
System::String outputPath = u"OutputDirectory\\email-to-pdf.pdf"; | |
// Save email as PDF | |
doc->Save(outputPath, Aspose::Words::SaveFormat::Pdf); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment