Bagikan melalui


MailMessage.BodyEncoding Properti

Definisi

Mendapatkan atau mengatur pengodean yang digunakan untuk mengodekan isi pesan.

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

Nilai Properti

Diterapkan Encoding pada konten Body.

Contoh

Contoh kode berikut menunjukkan pembuatan pesan email yang menggunakan pengodean UTF8.

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

Keterangan

Nilai yang ditentukan untuk BodyEncoding properti mengatur bidang kumpulan karakter di header Content-Type. Kumpulan karakter default adalah "us-ascii".

Jika Anda mengatur BodyEncoding properti ke UTF8, Unicode, atau UTF32, Kerangka Kerja memilih TransferEncoding dari Base64 untuk ini MailMessage.

Berlaku untuk

Lihat juga