MessageParserConfigParseHeaderOnly Property
Gets or sets if only the headers of the message should be parsed.

Namespace: MailBee.Mime
Assembly: MailBee.NET (in MailBee.NET.dll) Version: 11.2.0 build 590 for .NET 4.5
Syntax
public bool ParseHeaderOnly { get; set; }

Property Value

Type: Boolean
true if only the headers of the message should be parsed; otherwise, the entire message will be parsed. The default value is false.
Remarks

Parsing the message header only can save resources and improve performance in the case if only the headers is everything needed at the current moment. When downloading the message from the mail server, you can use methods which get just message headers. But when loading the message from a file or any other source which is not a mail server, you should use ParseHeaderOnly for that.

Unlike other properties of MessageParserConfig object which can be set both before and after calling LoadMessage(String) method, effect of ParseHeaderOnly differs depending on whether you called it BEFORE loading the message from a file (or stream) or AFTER. If you set ParseHeaderOnly BEFORE loading the message, the loading routine will not even load everything but the header from the file (or stream). If you set ParseHeaderOnly AFTER loading the message (but before accessing any of its properties which may trigger the parsing), the loading routine will already be completed to this moment and the entire message source will be read from the file (or stream); in this case, only the header of this message source will be parsed but the message source itself will be complete. For instance, you can then change ParseHeaderOnly value back to false and call Apply to re-parse this message completely this time. For instance, you can use this approach to preview messages during search: you read a message completely but parse only its header. If the header contains certain data (let's say, Subject of certain kind), you then reparse it completely and get the data you need. If Subject does not contain the required string, you discard the message and proceed to another one.

Note Note
MessageParserConfig object cannot be used on its own. To access its members, the developer should use MailMessage.Parser property.
Examples
This sample loads the message header from .EML file and displays the subject of this message.
// 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.ParseHeaderOnly = true;
msg.LoadMessage(@"C:\Docs\TestMail.eml");
Console.WriteLine(msg.Subject);
See Also