MessageParserConfigGetMessageFolder Method
Returns the full path to the folder where the message files were saved by GetHtmlAndSaveRelatedFiles or SaveHtmlAndRelatedFiles(String) method calls or by enabled message autosave mechanism.

Namespace: MailBee.Mime
Assembly: MailBee.NET (in MailBee.NET.dll) Version: 12.2.0 build 630 for .NET 4.5
public string GetMessageFolder()

Return Value

Type: String
A string containing the full path to the folder where the message files were saved due to calling GetHtmlAndSaveRelatedFiles or or SaveHtmlAndRelatedFiles(String) methods or due to parsing the message with enabled autosave mechanism, or a null reference (Nothing in Visual Basic) if no files have been saved yet (the methods above have not been called yet, the message with enabled autosave mechanism was not parsed yet, or the files saved by these methods have already been deleted on Reset or Dispose call).

For example, this method is useful when the message files were saved into the unique folder (created in WorkingFolder by GetHtmlAndSaveRelatedFiles(String, VirtualMappingType, MessageFolderBehavior) method with folderMode parameter set to CreateOnly). In this case, the unique folder is created but not automatically deleted when the MailMessage object gets destroyed. The developer can call this method to get the unique folder path, save it somewhere (such as ASP.NET Session) and then use this path to delete the folder later.

If GetHtmlAndSaveRelatedFiles(String, VirtualMappingType, MessageFolderBehavior) was called with folderMode set to DoNotCreate (or parameterless overload of GetHtmlAndSaveRelatedFiles was used), no unique folder is created, all message files are stored directly in WorkingFolder, and GetMessageFolder method returns either the same value as WorkingFolder property (if WorkingFolder was set to a full path) or the full path to WorkingFolder if its value was a relative path.

Automatic saving of the message files during parsing the message can be enabled with AutoSaveHtmlMode if required. By default, MailBee does not write anything to disk during parsing.

When WorkingFolder is a null reference, it's internally assumed that WorkingFolder specifies the system temporary folder of the current user. Thus, GetMessageFolder value will be different from WorkingFolder (which is a null reference) but the behaviour will be the same as described above (for instance, in regard to whether to create unique message sub-folders in the specified folder, etc).

The same is true if WorkingFolder is an empty string (the default value). Because, GetMessageFolder always returns the full path, in this case it will return the full path to the current folder of the application.

This sample demonstrates how to get the path of the folder with the message files if MailBee is configured to create unique folder specially for this message within the specified folder.
// 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).
MailMessage msg = new MailMessage();
msg.Parser.WorkingFolder = @"C:\Temp";
See Also