Gets or sets the Attachment object at the specified zero-based index in the collection.
An Attachment object having the specified zero-based index in the collection.
| Exception Type | Condition |
|---|---|
| ArgumentOutOfRangeException | The specified index does not exist. |
This sample loads the message from .EML file and saves the first attachment to disk.
[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"); // When there are any attachments... if (msg.Attachments.Count > 0) { // Get the attachment by its index. Attachment attach = msg.Attachments[0]; // Save the attachment to folder. attach.SaveToFolder(@"C:\Temp", true); }
[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") ' When there are any attachments... If msg.Attachments.Count > 0 Then ' Get the attachment by its index. Dim attach As Attachment = msg.Attachments(0) ' Save the attachment to the folder. attach.SaveToFolder("C:\Temp", True) End If
AttachmentCollection Class | MailBee.Mime Namespace | AttachmentCollection.Item Overload List | Item