MessageParserConfig Class |
Namespace: MailBee.Mime
The MessageParserConfig type exposes the following members.
Name | Description | |
---|---|---|
Apply |
Applies the current parsing options and re-parses the message.
| |
Equals | Determines whether the specified object is equal to the current object. (Inherited from Object.) | |
Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.) | |
GetHashCode | Serves as the default hash function. (Inherited from Object.) | |
GetMessageFolder |
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.
| |
GetMessageIDHash |
Returns SHA1 hash of the specified value, or SHA1 hash of the MessageID if no value specified.
| |
GetType | Gets the Type of the current instance. (Inherited from Object.) | |
MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) | |
Reset |
Resets the parsing settings to the default values.
| |
SetHtmlOutputMode |
Configures the parser to prepare the message for displaying in HTML container (such as browser).
| |
SetPlainOutputMode |
Configures the parser to prepare the message for displaying in plain-text container (such as a TextBox control in WinForms application or the console).
| |
ToString | Returns a string that represents the current object. (Inherited from Object.) |
Name | Description | |
---|---|---|
AHRefCleanup |
Gets or sets the options of processing <A HREF> tags in the HTML body.
| |
AHRefSuffix |
Gets or sets a string which should be added to all <A HREF> tags as their attribute.
| |
AutoSaveHtmlMode |
Gets or sets if (and how) the HTML body of the message should be saved to disk.
| |
CharsetConverter |
Gets the object which controls charset conversions of string values of
MailMessage properties when these values are returned to the application.
| |
CharsetMetaTagMode |
Gets or sets if (and how) <META> tags should be processed.
| |
DatesAsUtc |
Indicates whether MailBee should return datetime values adjusted to UTC (GMT) timezone.
| |
EncodingDefault |
Gets or sets Encoding to use when the charset is not specified in the e-mail message.
| |
EncodingOverride |
Gets or sets Encoding to use for decoding the message headers and text body parts from bytes to strings.
| |
FixCrLf |
Enables MailBee to replace single Lf characters with CrLf when extracting the plain-text body during parsing the message.
| |
HeadersAsHtml |
Gets or sets whether the message headers should be returned as HTML.
| |
HtmlToPlainMode |
Gets or sets the mode which specifies if the HTML body should be automatically converted into the plain text.
| |
HtmlToPlainOptions |
Gets or sets the options which affect how the HTML body of the message gets converted into plain text.
| |
HtmlToSimpleHtmlMode |
Gets or sets the mode which specifies when the HTML part of the message should be converted into simple HTML (plain text converted into HTML).
| |
HtmlToSimpleHtmlOptions |
Gets or sets the options which affect how the HTML part of the message gets converted into simple HTML.
| |
ParseHeaderOnly |
Gets or sets if only the headers of the message should be parsed.
| |
PlainToHtmlMode |
Gets or sets if the plain-text body of the message should be automatically converted into HTML.
| |
PlainToHtmlOptions |
Gets or sets options which affect how the plain-text message body gets converted into HTML.
| |
PlainToHtmlQuotationTag |
Gets or sets the string containing the tag to be used for highlighting quotations in the message.
| |
WorkingFolder |
Gets or sets the path to the temporary folder where the files related to the message should be stored.
| |
WriteUtf8ByteOrderMark |
Gets or sets if MailBee should add UTF-8 BOM when saving HTML files in UTF-8 encoding.
|
The properties and methods of this object allow you to fine-tune the process of parsing the message, processing HTML body, creating plain-text from HTML, saving embedded pictures, etc.
Note |
---|
MessageParserConfig object cannot be used on its own. To access its members, the developer should use MailMessage.Parser property. |
If you need more advanced methods to post-process HTML body (such as to remove or block unsafe content like Javascript or external images), consider using Processor class and HTML processing rules (for instance, GetSafeHtmlRules).
Note |
---|
The message will be parsed automatically if it was not yet parsed and the application requested any item of the message which can be obtained from parsed message only. For instance, reading Subject property or accessing Attachments collection will trigger the parser if the message was not parsed yet. However, in this sample we do not need any values of MailMessage properties and thus we request parsing explicitly using Apply method. |
using System; using MailBee; using MailBee.Pop3Mail; using MailBee.Mime; class Sample { static void Main(string[] args) { // Download the first message from the mail server. MailMessage msg = Pop3.QuickDownloadMessage("mail.domain.com", "jdoe", "secret", 1); // By default, MailBee does not store anything to disk during parsing messages. // Tell MailBee parser to save the message as message.htm file during parsing. msg.Parser.AutoSaveHtmlMode = HtmlMessageAutoSaving.SaveMessageHtmAndRelatedFiles; // By default, MailBee does not create HTML version for plain-text messages. To // make sure the created message.htm will not be empty in the case of plain-text // message, tell MailBee to create HTML version (which will then be saved as // message.htm file). Thus, if the message does contain HTML version, it will be // used. If not, MailBee will generate it. msg.Parser.PlainToHtmlMode = PlainToHtmlAutoConvert.IfNoHtml; // By default, message.htm would be saved in the current folder of the application. // Tell MailBee to save message.htm and related files into another location. msg.Parser.WorkingFolder = @"C:\Docs"; // Apply parsing and make message.htm file be saved. Alternatively, we could have // just called reading msg.Subject or similar property to trigger the parser. // However, it would not be elegant approach. Also, Apply method will make the // message get reparsed if it was already parsed. This is not used in the current // sample but can be helpful if you need to apply different parsing settings to // the same message. msg.Parser.Apply(); // Show the path of the folder where message.htm was saved. Console.WriteLine(msg.Parser.GetMessageFolder()); } }