Indicates if the attachment contains a mail message.
true if the attachment is a mail message; otherwise, false.
For instance, if the mail message was forwarded as attachment to another message, the developer can use this property to determine whether the attachment contains the forwarded message. If it does, GetEncapsulatedMessage method can be used to extract the encapsulated MailMessage object from the attachment.
This sample loads the message from .EML file and displays subjects of all attached e-mails.
[C#] // To use the code below, import MailBee namespaces at the top of your code. using MailBee; using MailBee.Mime; // The actual code (put it into a method of your class) // Load the message from file. MailMessage msg = new MailMessage(); msg.LoadMessage(@"C:\Docs\TestMail.eml"); // For every attachment... foreach (Attachment attach in msg.Attachments) { // ...when the attachment is an e-mail message... if (attach.IsMessageInside) { // ...then extract the e-mail message from the attachment... MailMessage attachedMsg = attach.GetEncapsulatedMessage(); // and show its Subject field. Console.WriteLine("Forwarded message subject is " + attachedMsg.Subject); } }
[Visual Basic] ' To use the code below, import MailBee namespaces at the top of your code. Imports MailBee Imports MailBee.Mime ' The actual code (put it into a method of your class) ' Load the message from file. Dim msg As New MailMessage msg.LoadMessage("C:\Docs\TestMail.eml") ' For every attachment... For Each attach As Attachment In msg.Attachments ' ...when the attachment is an e-mail message... If attach.IsMessageInside Then ' ...then extract the e-mail message from the attachment... Dim attachedMsg As MailMessage = attach.GetEncapsulatedMessage() ' and show its Subject field. Console.WriteLine("Forwarded message subject is " & attachedMsg.Subject) End If Next
Attachment Class | MailBee.Mime Namespace | GetEncapsulatedMessage | MailMessage