MessageParserConfigGetMessageFolder Method |
Namespace: MailBee.Mime
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.
// 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.LoadMessage(@"C:\Docs\TestMail.eml"); msg.Parser.WorkingFolder = @"C:\Temp"; Console.WriteLine(msg.GetHtmlAndSaveRelatedFiles(@"C:\Temp", VirtualMappingType.NonWeb, MessageFolderBehavior.CreateAndDelete)); Console.WriteLine(msg.Parser.GetMessageFolder());