AttachmentSaveToFolder Method
Saves the content of the attachment into a file in the specified folder.

Namespace: MailBee.Mime
Assembly: MailBee.NET (in MailBee.NET.dll) Version: 12.2.0 build 630 for .NET 4.5
public bool SaveToFolder(
	string folderName,
	bool overwrite


Type: SystemString
The absolute or relative path to the folder where the attachment file should be saved.
Type: SystemBoolean
Specifies 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.
MailBeeIOExceptionAn error occurred and ThrowExceptions is true.
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(String, Boolean) method.
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.
This sample downloads the message from POP3 account and saves all the message attachments into the specified folder. ,
Note Note
SaveToFolder(String, Boolean) method is used for demonstration purposes only. Real-world applications can use the SaveAll(String) method to save all the message attachments into the specified folder with a single method call.
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("", "jdoe", "password", 1);

        // For every attachment...
        foreach (Attachment attach in msg.Attachments)
            // it into the specified folder.
            attach.SaveToFolder(@"C:\Temp\", true);
See Also