Saves the content of the attachment into the specified file.
true if the attachment was successfully saved to disk; otherwise, false.
The developer can use SaveToFolder 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.
| Exception Type | Condition |
|---|---|
| MailBeeIOException | An error occurred and ThrowExceptions is true. |
This sample loads the message from .EML file and saves all the attachments to disk.
[C#] // 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); }
[Visual Basic] ' To use the code below, import MailBee namespaces at the top of your code. Imports MailBee Imports MailBee.Mime ' The actual code (put it into a method of your class) ' Load the message from file. Dim msg As New MailMessage msg.LoadMessage("C:\Docs\TestMail.eml") ' For every attachment... For Each attach As Attachment In msg.Attachments ' ...save it to disk. attach.Save("C:\Temp\" & attach.Filename, True) Next
Attachment Class | MailBee.Mime Namespace | SaveToFolder