MimePartCharset Property
Gets the name of the character encoding of the MIME part.

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

Property Value

Type: String
A string containing the name of the character encoding of the MIME part, or an empty string if the charset is not specified in the MIME part.

For instance, if Content-Type header string is Content-Type: text/plain; charset="EUC-KR", this property will return EUC-KR value.

Note Note
Although MimePartTree object represents the root MIME part of the message and thus headers of that MimePart are the same as headers of the MailMessage itself, there still can be difference between msg.Charset and msg.MimePartRoot.Charset values. This is because msg.MimePartRoot.Charset always returns the charset information specified in the headers of this MIME part, while msg.Charset returns the charset specified in another MIME part in the case if the root part of the message does not contain the charset information but any of the nested parts does. This is common case for multi-part messages because multi-part parts do not contain charset information. Use MailMessage.Charset to determine the overall charset of the message.
This sample loads the message from .EML file and displays the charset of the message as specified in the root part. This value will be empty if the message is multi-part (for instance, contains attachments or alternative plain-text body).
// 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)

// Load the message from file.
MailMessage msg = new MailMessage();

// Show the charset specified in the message headers.
See Also