MessageParserConfig Class
Provides properties and methods which affect how the mail message is being parsed from the raw data (MIME source) into the MailMessage object properties and collections.
Inheritance Hierarchy

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

The MessageParserConfig type exposes the following members.

Public methodCode exampleApply
Applies the current parsing options and re-parses the message.
Public methodEquals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Protected methodFinalize
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object.)
Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Public methodCode exampleGetMessageFolder
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.
Public methodGetMessageIDHash
Returns SHA1 hash of the specified value, or SHA1 hash of the MessageID if no value specified.
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Public methodReset
Resets the parsing settings to the default values.
Public methodSetHtmlOutputMode
Configures the parser to prepare the message for displaying in HTML container (such as browser).
Public methodCode exampleSetPlainOutputMode
Configures the parser to prepare the message for displaying in plain-text container (such as a TextBox control in WinForms application or the console).
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Public propertyCode exampleAHRefCleanup
Gets or sets the options of processing <A HREF> tags in the HTML body.
Public propertyCode exampleAHRefSuffix
Gets or sets a string which should be added to all <A HREF> tags as their attribute.
Public propertyCode exampleAutoSaveHtmlMode
Gets or sets if (and how) the HTML body of the message should be saved to disk.
Public propertyCharsetConverter
Gets the object which controls charset conversions of string values of MailMessage properties when these values are returned to the application.
Public propertyCode exampleCharsetMetaTagMode
Gets or sets if (and how) <META> tags should be processed.
Public propertyDatesAsUtc
Indicates whether MailBee should return datetime values adjusted to UTC (GMT) timezone.
Public propertyEncodingDefault
Gets or sets Encoding to use when the charset is not specified in the e-mail message.
Public propertyEncodingOverride
Gets or sets Encoding to use for decoding the message headers and text body parts from bytes to strings.
Public propertyFixCrLf
Enables MailBee to replace single Lf characters with CrLf when extracting the plain-text body during parsing the message.
Public propertyCode exampleHeadersAsHtml
Gets or sets whether the message headers should be returned as HTML.
Public propertyCode exampleHtmlToPlainMode
Gets or sets the mode which specifies if the HTML body should be automatically converted into the plain text.
Public propertyCode exampleHtmlToPlainOptions
Gets or sets the options which affect how the HTML body of the message gets converted into plain text.
Public propertyCode exampleHtmlToSimpleHtmlMode
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).
Public propertyCode exampleHtmlToSimpleHtmlOptions
Gets or sets the options which affect how the HTML part of the message gets converted into simple HTML.
Public propertyCode exampleParseHeaderOnly
Gets or sets if only the headers of the message should be parsed.
Public propertyCode examplePlainToHtmlMode
Gets or sets if the plain-text body of the message should be automatically converted into HTML.
Public propertyCode examplePlainToHtmlOptions
Gets or sets options which affect how the plain-text message body gets converted into HTML.
Public propertyCode examplePlainToHtmlQuotationTag
Gets or sets the string containing the tag to be used for highlighting quotations in the message.
Public propertyCode exampleWorkingFolder
Gets or sets the path to the temporary folder where the files related to the message should be stored.
Public propertyWriteUtf8ByteOrderMark
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 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).

This sample creates a new message, tells MailBee parser to save the message as message.htm file (and related files if any) during parsing the message, and parses the message to make message.htm be saved.
Note 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("", "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.

        // Show the path of the folder where message.htm was saved.
See Also