Gets the attachment as MimePart object.
A MimePart object representing the attachment of the mail message as a MIME part.
MimePart corresponding to the given attachment provides access to those properties that are not available in Attachment but accessible in MimePart only.
To get the root part of the MIME parts tree of the message, use MimePartTree property of MailMessage object. MimePartTree MIME part contains all the MIME parts of the message.
This sample loads the message from .EML file and displays Content-Disposition of all attachments of this message. Content-Disposition value is not available in Attachment object but can be retrieved using MimePart object.
[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) { // ...show the filename and content-disposition of the attachment. Console.WriteLine("Attachment name: " + attach.Filename); Console.WriteLine("Disposition: " + attach.AsMimePart.Disposition); Console.WriteLine(); }
[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 ' ...show the filename and content-disposition of the attachment. Console.WriteLine("Attachment name: " & attach.Filename) Console.WriteLine("Disposition: " & attach.AsMimePart.Disposition) Console.WriteLine() Next
Attachment Class | MailBee.Mime Namespace