AttachmentGetEncapsulatedMessage Method |
Gets the encapsulated e-mail message as a
MailMessage object.
Namespace: MailBee.MimeAssembly: MailBee.NET (in MailBee.NET.dll) Version: 12.5.0 build 687 for .NET 4.5
Syntax public MailMessage GetEncapsulatedMessage()
Public Function GetEncapsulatedMessage As MailMessage
Return Value
Type:
MailMessage
A
MailMessage object containing the encapsulated e-mail message, or a null reference
(
Nothing in Visual Basic) if the attachment is not an e-mail message.
Remarks
This method extracts the encapsulated e-mail message from the attachment content, and represents it as
a
MailMessage object for any further use. The extracted message can then be easily examined,
resent, replied, saved to disk, or processed in any other way.
Note |
---|
To detect if the attachment is an e-mail message, the developer can use IsMessageInside property.
|
Examples This sample loads the message from .EML file, extracts the encapsulated message, and displays
all headers of the encapsulated message.
using MailBee;
using MailBee.Mime;
MailMessage msg = new MailMessage();
msg.LoadMessage(@"C:\Docs\TestMail.eml");
MailMessage attachedMsg = null;
foreach (Attachment attach in msg.Attachments)
{
attachedMsg = attach.GetEncapsulatedMessage();
if (attachedMsg != null)
{
Console.WriteLine(attachedMsg.RawHeader);
Console.WriteLine();
}
}
Imports MailBee
Imports MailBee.Mime
Dim msg As New MailMessage
msg.LoadMessage("C:\Docs\TestMail.eml")
Dim attachedMsg As MailMessage = Nothing
For Each attach As Attachment In msg.Attachments
attachedMsg = attach.GetEncapsulatedMessage()
If Not attachedMsg Is Nothing Then
Console.WriteLine(attachedMsg.RawHeader)
Console.WriteLine()
End If
Next
See Also