AttachmentCollectionAdd Method (String, String) |
Adds the attachment from a file.
Namespace: MailBee.MimeAssembly: MailBee.NET (in MailBee.NET.dll) Version: 12.5.0 build 687 for .NET 4.5
Syntax public bool Add(
string filename,
string targetFilename
)
Public Function Add (
filename As String,
targetFilename As String
) As Boolean
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.
Return Value
Type:
Booleantrue if the attachment was successfully added; otherwise,
false.
Exceptions 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 loads the message from .EML file and adds an attachment to this message.
using MailBee;
using MailBee.Mime;
MailMessage msg = new MailMessage();
msg.LoadMessage(@"C:\Docs\TestMail.eml");
msg.Attachments.Add(@"C:\Docs\pict1.tmp","map.jpg");
Imports MailBee
Imports MailBee.Mime
Dim msg As New MailMessage
msg.LoadMessage("C:\Docs\TestMail.eml")
msg.Attachments.Add("C:\Docs\pict1.tmp", "map.jpg")
See Also