AttachmentCollectionAdd Method (MailMessage, String, String, String, HeaderCollection, NewAttachmentOptions, MailTransferEncoding)
Adds the specified the MailMessage as attachment (i.e. forwards that message as attachment).

Namespace: MailBee.Mime
Assembly: MailBee.NET (in MailBee.NET.dll) Version: 11.2.0 build 590 for .NET 4.5
public void Add(
	MailMessage message,
	string targetFilename,
	string contentID,
	string contentType,
	HeaderCollection customHeaders,
	NewAttachmentOptions options,
	MailTransferEncoding mailEnc


Type: MailBee.MimeMailMessage
The mail message to be added as attachment.
Type: SystemString
The filename under which to add the attachment into the collection. If a null reference (Nothing in Visual Basic), MailBee will take it from the Subject of the message being attached. If an empty string, the attachment will have no name.
Type: SystemString
The content identifier (CID) of the attachment (for inline attachments), or empty string if the attachment is not inline.
Type: SystemString
The content type of the attachment. If a null reference (Nothing in Visual Basic), message/rfc822 value is used.
Type: MailBee.MimeHeaderCollection
The collection of the headers which should be included into the header section in additon to the standard attachment headers. If a null reference (Nothing in Visual Basic), no custom headers will be added.
Type: MailBee.MimeNewAttachmentOptions
The options which affect how the attachment is added.
Type: MailBee.MimeMailTransferEncoding
The mail encoding to use when placing the attachment data into the message.
MailBeeInvalidArgumentExceptionmessage is a null reference (Nothing in Visual Basic).
This method can be used to forward mail messages with another mail message. To forward a single message, it's easier to use ForwardAsAttachment method.
The following example demonstrates how a mail message can be attached to another mail message.
// 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 messageToAttach = new MailMessage();

// Create new MailMessage object.
MailMessage msg = new MailMessage();

// Set plain text body of the message.
msg.BodyPlainText = "Hello, World!";

// Add the attachment to the message.
msg.Attachments.Add(messageToAttach, "original.eml", "", "message/rfc822", null, NewAttachmentOptions.Inline, MailTransferEncoding.None);

// Save message to disk.
See Also