AttachmentSavedAs Property
Gets the full path to the attachment which was saved to disk.

Namespace: MailBee.Mime
Assembly: MailBee.NET (in MailBee.NET.dll) Version: 12.2.0 build 630 for .NET 4.5
Syntax
public string SavedAs { get; }

Property Value

Type: String
A string containing the full path to the attachment which was saved to disk, or empty string if the attachment was not saved to disk yet.
Remarks

This property is especially useful when the attachment was saved to disk implicitly (for instance, when all embedded pictures/files referenced in the HTML body were saved to disk by GetHtmlAndSaveRelatedFiles method call, and the developer wants to know the exact paths to the saved files).

Filenames of such files depend on the way they were saved. Usually attachments are saved under the path specified by the developer if saving was explicit (e.g. with Save(String, Boolean) method); or if saving was implicit (e.g. with GetHtmlAndSaveRelatedFiles method), attachments are saved to MailMessage.Parser.WorkingFolder.

This property can also be set by GetHtmlAndSaveRelatedFiles(String, VirtualMappingType, MessageFolderBehavior) and similar methods when mappingType was set to StaticInMemory (even though no actual files are saved by MailBee in this case). In that mode, it's your app's responsibility to make sure the file is accessible via SavedAs path when being accessed via web.

If mappingType was set to Base64 (so that GetHtmlAndSaveRelatedFiles(String, VirtualMappingType, MessageFolderBehavior) method embedded the attachment contents right into the HTML body), this property won't be set and will remain an empty string.

Examples
This sample loads the message from .EML file, saves every attachment to disk specifying only the folder, and displays the full path to each saved file.
// 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 the attachment into the specified folder overwriting the existing file if necessary,
    attach.SaveToFolder(@"C:\Temp\", true);

    // and show the full path to the saved file.
    Console.WriteLine("The path is " + attach.SavedAs);
}
See Also