Saves the content of the attachment into the specified file.
Namespace: MailBee.MimeAssembly: MailBee.NET (in MailBee.NET.dll) Version: 12.5.0 build 687 for .NET 4.5
Syntax public bool Save(
string filename,
bool overwrite
)
Public Function Save (
filename As String,
overwrite As Boolean
) As Boolean
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:
Booleantrue if the attachment was successfully saved to disk; otherwise,
false.
Exceptions Remarks
The developer can use
SaveToFolder(String, Boolean) method to save the attachment
into specified folder under the actual filename of the attachment.
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.
using MailBee;
using MailBee.Mime;
MailMessage msg = new MailMessage();
msg.LoadMessage(@"C:\Docs\TestMail.eml");
foreach (Attachment attach in msg.Attachments)
{
attach.Save(@"C:\Temp\" + attach.Filename, true);
}
Imports MailBee
Imports MailBee.Mime
Dim msg As New MailMessage
msg.LoadMessage("C:\Docs\TestMail.eml")
For Each attach As Attachment In msg.Attachments
attach.Save("C:\Temp\" & attach.Filename, True)
Next
See Also