MailBee.NET Objects 4.0

TextBodyPart.Charset Property

Gets or sets the charset of the text part contents.

public string Charset {get; set;}

Property Value

A string containing the name of the charset of the text body part contents, or an empty string if the charset is not specified in the message.

Remarks

When composing a message, you can use this property to set different charsets for different text parts of the message.

It has no effect on parsing messages. To set the encoding to be used during parsing messages, use EncodingDefault or EncodingOverride properties.

Example

This sample creates a new message with HTML and plain-text bodies, sets different charsets for these bodies, and save the message to disk.

[C#]
// 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.BodyHtmlText = "<b>Hello</b>, <i>World</i>!";
msg.BodyParts.Html.Charset = "utf-8";
msg.BodyPlainText = "Hello, World!";
msg.BodyParts.Plain.Charset = "us-ascii";
msg.SaveMessage(@"C:\Docs\TestMail.eml");
[Visual Basic]
' 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.BodyHtmlText = "<b>Hello</b>, <i>World</i>!"
msg.BodyParts.Html.Charset = "utf-8"
msg.BodyPlainText = "Hello, World!"
msg.BodyParts.Plain.Charset = "us-ascii"
msg.SaveMessage("C:\Docs\TestMail.eml")

See Also

TextBodyPart Class | MailBee.Mime Namespace | Charset