MailBee.NET Objects 7.2

AttachmentCollection.Remove Method 

Removes the attachment having the specified unique name from the collection.

public bool Remove(
   string filename
);

Parameters

filename
The unique name of the attachment (as returned by Filename property) to be removed.

Return Value

true if the specified attachment was successfully removed; otherwise, false.

Remarks

The developer can also use RemoveAt method to remove the attachment by its integer zero-based index in the collection.

Exceptions

Exception Type Condition
MailBeeInvalidArgumentException filename is a null reference (Nothing in Visual Basic).

Example

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")

See Also

AttachmentCollection Class | MailBee.Mime Namespace | Attachment