MailBee.NET Objects 6.0

AttachmentCollection.RemoveAt Method 

Removes the attachment with the specified index from the collection.

new public void RemoveAt(
   int index
);

Parameters

index
The zero-based index of the attachment to be removed.

Return Value

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

Implements

IList.RemoveAt

Exceptions

Exception Type Condition
ArgumentOutOfRangeException The specified index does not exist.

Example

This sample loads the message from .EML file and removes the first attachment from the message.

[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 first attachment from the collection.
msg.Attachments.RemoveAt(0);
[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 first attachment from the collection.
msg.Attachments.RemoveAt(0)

See Also

AttachmentCollection Class | MailBee.Mime Namespace | Remove