MailMessageCharset Property
Gets or sets the name of the charset which was used to compose the message.

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

Property Value

Type: String
A string containing the name of the charset which was used to compose the message, or an empty string if the charset is not specified. The default value for new messages is utf-8.

Every part of an e-mail message may have its own charset (although it's not recommended). E-mails composed with MailBee have the same charset value across the message (unless you manually specified different charsets of text parts using TextBodyPart.Charset property). If text parts of the message (originally composed with another program and being parsed with MailBee now) have different charsets, Charset property will return charset of the last text part of this message.

For existing e-mail messages being parsed (rather than for new messages being composed) Charset property value is not important for the developer because MailBee automatically converts the message content accordingly the charset information in the message and the application receives the already decoded content. In this case, Charset property value has the informative feature only.

However, when composing a new message (with international characters), you should specify the charset using Charset property in case if you don't want UTF-8 encoding. Or, in rare cases, you will use TextBodyPart.Charset property if you need different charset settings for different text parts.

If Charset is not specified, MailBee will use the following properties to determine encoding for string-to-byte and byte-to-string conversions:

Setting Charset property will overwrite TextBodyPart.Charset values for all text parts of the message. But if you specified TextBodyPart.Charset value for a certain text part AFTER Charset had been set, that text part will retain the specified TextBodyPart.Charset in the resulting message (while Charset will be used for other text parts of the message).

Note Note
If any characters of the message contents are not defined in the specified charset, they will be replaced with "?" characters.
The example is available in MailMessage topic.
See Also