MailBee.NET Objects 3.1

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.

For a list of all members of this type, see MessageParserConfig Members.

System.Object
   MailBee.Mime.MessageParserConfig

public class MessageParserConfig

Thread Safety

Public static (Shared in Visual Basic) members of this type are safe for multithreaded operations. Instance members are not guaranteed to be thread-safe.

Remarks

MessageParserConfig object cannot be used on its own. To access its members, the developer should use MailMessage.Parser property.

Example

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   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.
[C#]
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());
    }
}
[Visual Basic]
Imports System
Imports MailBee
Imports MailBee.Pop3Mail
Imports MailBee.Mime

Class Sample
    Shared Sub Main(ByVal args() As String)
        ' Download the first message from the mail server.
        Dim msg As MailMessage = 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())
    End Sub
End Class

Requirements

Namespace: MailBee.Mime

Assembly: MailBee.NET (in MailBee.NET.dll)

See Also

MessageParserConfig Members | MailBee.Mime Namespace | Parser | Builder