Saves the content of the attachment into a file in the specified folder.
true if the attachment was successfully saved to disk; otherwise, false.
This method saves the attachment content to the folder under the actual filename of the attachment (which is taken from Filename property). To save the attachment under another filename, use the Save method.
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 downloads the message from POP3 account and saves all the message attachments into the specified folder. ,
Note SaveToFolder method is used for demonstration purposes only. Real-world applications can use the SaveAll method to save all the message attachments into the specified folder with a single method call.
[C#] using MailBee; using MailBee.Pop3Mail; using MailBee.Mime; class Sample { static void Main(string[] args) { // Quickly download the first message from the specified POP3 account. MailMessage msg = Pop3.QuickDownloadMessage("pop3.mail.com", "jdoe", "password", 1); // For every attachment... foreach (Attachment attach in msg.Attachments) { // ...save it into the specified folder. attach.SaveToFolder(@"C:\Temp\", true); } } }
[Visual Basic] Imports MailBee Imports MailBee.Pop3Mail Imports MailBee.Mime Module Sample Sub Main(ByVal args As String()) ' Quickly download the first message from the specified POP3 account. Dim msg As MailMessage = Pop3.QuickDownloadMessage("pop3.mail.com", "jdoe", "password", 1) ' For every attachment... For Each attach As Attachment In msg.Attachments ' ...save it into the specified folder. attach.SaveToFolder("C:\Temp\", True) Next End Sub End Module
Attachment Class | MailBee.Mime Namespace | Save