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 usefor that.
Unlike other properties of MessageParserConfig object which can be set both before and after calling LoadMessage(String) method, effect of differs depending on whether you called it BEFORE loading the message from a file (or stream) or AFTER. If you set BEFORE loading the message, the loading routine will not even load everything but the header from the file (or stream). If you set 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 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.
// 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);
' To use the code below, import MailBee namespaces at the top of your code. Imports MailBee Imports MailBee.Mime ' The actual code (put it into a method of your class). Dim msg As New MailMessage msg.Parser.ParseHeaderOnly = True msg.LoadMessage("C:\Docs\TestMail.eml") Console.WriteLine(msg.Subject)