MailMessage.BodyEncoding プロパティ

定義

メッセージ本文をエンコードするために使用されるエンコーディングを取得または設定します。Gets or sets the encoding used to encode the message body.

public:
 property System::Text::Encoding ^ BodyEncoding { System::Text::Encoding ^ get(); void set(System::Text::Encoding ^ value); };
public System.Text.Encoding? BodyEncoding { get; set; }
public System.Text.Encoding BodyEncoding { get; set; }
member this.BodyEncoding : System.Text.Encoding with get, set
Public Property BodyEncoding As Encoding

プロパティ値

Encoding

Encoding の内容に対して適用される BodyAn Encoding applied to the contents of the Body.

次のコード例は、UTF8 エンコードを使用するメールメッセージを作成する方法を示しています。The following code example demonstrates creating a mail message that uses UTF8 encoding.

MailMessage^ message = gcnew MailMessage(from, to);
message->Body = "This is a test email message sent" +
    " by an application. ";
// Include some non-ASCII characters in body and 
// subject.
String^ someArrows = gcnew String(gcnew array<wchar_t>{L'\u2190', 
    L'\u2191', L'\u2192', L'\u2193'});
message->Body += Environment::NewLine + someArrows;
message->BodyEncoding = System::Text::Encoding::UTF8;
message->Subject = "test message 1" + someArrows;
message->SubjectEncoding = System::Text::Encoding::UTF8;
MailMessage message = new MailMessage(from, to);
message.Body = "This is a test email message sent by an application. ";
// Include some non-ASCII characters in body and subject.
string someArrows = new string(new char[] {'\u2190', '\u2191', '\u2192', '\u2193'});
message.Body += Environment.NewLine + someArrows;
message.BodyEncoding =  System.Text.Encoding.UTF8;
message.Subject = "test message 1" + someArrows;
message.SubjectEncoding = System.Text.Encoding.UTF8;
Dim message As New MailMessage(mailFrom, mailTo)
message.Body = "This is a test email message sent by an application. "
' Include some non-ASCII characters in body and subject.
Dim someArrows As New String(New Char() {ChrW(&H2190), ChrW(&H2191), ChrW(&H2192), ChrW(&H2193)})
message.Body += Environment.NewLine & someArrows
message.BodyEncoding = System.Text.Encoding.UTF8
message.Subject = "test message 1" & someArrows
message.SubjectEncoding = System.Text.Encoding.UTF8

注釈

プロパティに指定された値によって、 BodyEncoding content-type ヘッダーの文字セットフィールドが設定されます。The value specified for the BodyEncoding property sets the character set field in the Content-Type header. 既定の文字セットは "us-ascii" です。The default character set is "us-ascii".

BodyEncodingプロパティを、、またはに設定すると、 UTF8 Unicode UTF32 フレームワークはこのののを選択 TransferEncoding Base64 MailMessage します。If you set the BodyEncoding property to UTF8, Unicode, or UTF32, the Framework selects a TransferEncoding of Base64 for this MailMessage.

適用対象

こちらもご覧ください