Removes the attachment having the specified unique name from the collection.
true if the specified attachment was successfully removed; otherwise, false.
The developer can also use RemoveAt method to remove the attachment by its integer zero-based index in the collection.
| Exception Type | Condition |
|---|---|
| MailBeeInvalidArgumentException | filename is a null reference (Nothing in Visual Basic). |
This sample loads the message from .EML file and removes the attachment with me.jpg filename.
[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"); // Remove the specified attachment from the collection. msg.Attachments.Remove("me.jpg");
[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") ' Remove the specified attachment from the collection. msg.Attachments.Remove("me.jpg")
AttachmentCollection Class | MailBee.Mime Namespace | Attachment