AttachmentSave Method
Saves the content of the attachment into the specified file.

Namespace: MailBee.Mime
Assembly: MailBee.NET (in MailBee.NET.dll) Version: 11.2.0 build 590 for .NET 4.5
Syntax
public bool Save(
	string filename,
	bool overwrite
)

Parameters

filename
Type: SystemString
The absolute or relative path under which to save the attachment.
overwrite
Type: SystemBoolean
Denotes if the file must be overwritten if it already exists.

Return Value

Type: Boolean
true if the attachment was successfully saved to disk; otherwise, false.
Exceptions
ExceptionCondition
MailBeeIOExceptionAn error occurred and ThrowExceptions is true.
Remarks
The developer can use SaveToFolder(String, Boolean) method to save the attachment into specified folder under the actual filename of the attachment.
Note Note
If overwrite is false and the file with the same filename already exists, the attachment will be saved under another name. For instance, if cat.gif is being saved and such file already exists, it will be actually saved as cat[1].gif. The developer can use SavedAs property to obtain the filename of the saved file.
Examples
This sample loads the message from .EML file and saves all the attachments to disk.
// 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");

// For every attachment...
foreach (Attachment attach in msg.Attachments)
{
    // ...save it to disk.
    attach.Save(@"C:\Temp\" + attach.Filename, true);
}
See Also