AttachmentCollectionAdd Method (String, String, String)
Adds the attachment from a file.

Namespace: MailBee.Mime
Assembly: MailBee.NET (in MailBee.NET.dll) Version: 12.4 build 677 for .NET 4.5
Syntax
public bool Add(
	string filename,
	string targetFilename,
	string contentID
)

Parameters

filename
Type: SystemString
The absolute or relative path to the file which should be attached.
targetFilename
Type: SystemString
The filename of the attachment as it should appear in the mail message. If a null reference (Nothing in Visual Basic), MailBee will take it from filename parameter value. If an empty string, the attachment will have no name.
contentID
Type: SystemString
The content identifier (CID) of the attachment (for inline attachments), or empty string if the attachment is not inline.

Return Value

Type: Boolean
true if the attachment was successfully added; otherwise, false.
Exceptions
ExceptionCondition
MailBeeInvalidArgumentExceptionfilename is a null reference (Nothing in Visual Basic) or an empty string.
MailBeeIOExceptionAn error occurred and ThrowExceptions is true.
Remarks
The targetFilename parameter allows the developer to override the filename under which the attachment will be added to the collection. This is useful when the developer wants to add the attachment from a temporary file such as ETQB4914.TMP under meaningful name such as report.doc.
Examples
This sample creates a new message and adds an attachment to this message.
// To use the code below, import MailBee namespaces at the top of your code.
using MailBee;
using MailBee.Mime;

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

// Add the attachment to the message.
msg.Attachments.Add(@"C:\Temp\mypic.gif", "my.gif","<00s4a8m8918c$5664i1b1$iw671781@tlffmdqjobxj>");
See Also