Last active
April 22, 2021 12:10
-
-
Save aspose-com-gists/92bebfb96a8d9e0a154eca412c107a5d to your computer and use it in GitHub Desktop.
Read Email Messages 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
Examples for reading Email Messages 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
// Create MailMessage instance by loading an EML file | |
System::SharedPtr<MailMessage> message = MailMessage::Load(u"SourceDirectory\\Message.eml", System::MakeObject<EmlLoadOptions>()); | |
// Get decoded value from the header | |
System::String decodedValue = message->get_Headers()->GetDecodedValue(u"Thread-Topic"); | |
// Print the value | |
System::Console::WriteLine(decodedValue); |
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
// Create MailMessage instance by loading an EML file | |
System::SharedPtr<MailMessage> message = MailMessage::Load(u"SourceDirectory\\Message.eml", System::MakeObject<EmlLoadOptions>()); | |
// Print out all the headers | |
int32_t index = 0; | |
{ | |
auto header_enumerator = message->get_Headers()->GetEnumerator(); | |
decltype(header_enumerator->get_Current()) header; | |
while (header_enumerator->MoveNext() && (header = header_enumerator->get_Current(), true)) | |
{ | |
System::Console::Write(header + u" - "); | |
System::Console::WriteLine(message->get_Headers()->Get(index++)); | |
} | |
} |
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
// Create MailMessage instance by loading an EML file | |
System::SharedPtr<MailMessage> message = MailMessage::Load(u"SourceDirectory\\Message.eml", System::MakeObject<EmlLoadOptions>()); | |
// Get the sender info | |
System::Console::WriteLine(u"From:"); | |
System::Console::WriteLine(message->get_From()); | |
// Get the recipients info | |
System::Console::WriteLine(u"To:"); | |
System::Console::WriteLine(message->get_To()); | |
// Get the subject | |
System::Console::WriteLine(u"Subject:"); | |
System::Console::WriteLine(message->get_Subject()); | |
// Get the HTML body | |
System::Console::WriteLine(u"HtmlBody:"); | |
System::Console::WriteLine(message->get_HtmlBody()); | |
// Get the text body | |
System::Console::WriteLine(u"TextBody:"); | |
System::Console::WriteLine(message->get_Body()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment