MessageParserConfigCharsetMetaTagMode Property
Gets or sets if (and how) <META> tags should be processed.

Namespace: MailBee.Mime
Assembly: MailBee.NET (in MailBee.NET.dll) Version: 12.2.0 build 630 for .NET 4.5
public CharsetMetaTagProcessing CharsetMetaTagMode { get; set; }

Property Value

Type: CharsetMetaTagProcessing
The method of processing <META> tags which contain charset information. The default value is DoNothing.

This property can be used to enable modification of <META> containing the charset specification of the HTML body. HTML messages often contain tags like <META content="xxxxxx; charset=xxxxxx">. However, if the application displays everything in another charset (usually, UTF-8), this charset specification will no longer be valid. It's recommended to remove it from the body by setting CharsetMetaTagMode to RemoveCharsetMetaTag before the message gets parsed. When no charset is specified in <META> tag, the client browser will obtain it from the web page header where it will already be correctly specified by ASP.NET engine.

Note Note
MessageParserConfig object cannot be used on its own. To access its members, the developer should use MailMessage.Parser property.
This sample loads the message from .EML file and sets the correct charset in META tag of the HTML body. Because it's not yet known which charset will be used to print the HTML body contents on the web page, <META content="xxxxxx; charset=xxxxxx"> tag will be simply removed. This is usually OK since the correct charset information will be available in the web page header.
// 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.CharsetMetaTagMode = CharsetMetaTagProcessing.SetCorrectCharset;
See Also