AttachmentSavedAs Property |
Namespace: MailBee.Mime
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.
// 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); }