AttachmentSaveToFolder Method |
Saves the content of the attachment into a file in the specified folder.
Namespace: MailBee.MimeAssembly: MailBee.NET (in MailBee.NET.dll) Version: 12.5.0 build 687 for .NET 4.5
Syntax public bool SaveToFolder(
string folderName,
bool overwrite
)
Public Function SaveToFolder (
folderName As String,
overwrite As Boolean
) As Boolean
Parameters
- folderName
- Type: SystemString
The absolute or relative path to the folder where the attachment file should be saved. - overwrite
- Type: SystemBoolean
Specifies 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
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 |
---|
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 downloads the message from POP3 account and saves all the message attachments into the specified folder. ,
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)
{
MailMessage msg = Pop3.QuickDownloadMessage("pop3.mail.com", "jdoe", "password", 1);
foreach (Attachment attach in msg.Attachments)
{
attach.SaveToFolder(@"C:\Temp\", true);
}
}
}
Imports MailBee
Imports MailBee.Pop3Mail
Imports MailBee.Mime
Module Sample
Sub Main(ByVal args As String())
Dim msg As MailMessage = Pop3.QuickDownloadMessage("pop3.mail.com", "jdoe", "password", 1)
For Each attach As Attachment In msg.Attachments
attach.SaveToFolder("C:\Temp\", True)
Next
End Sub
End Module
See Also