MailMessage.SubjectEncoding MailMessage.SubjectEncoding MailMessage.SubjectEncoding MailMessage.SubjectEncoding Property

定義

取得或設定這個電子郵件訊息之主旨內容所用的編碼方式。Gets or sets the encoding used for the subject content for this email message.

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

屬性值

Encoding,用來對 Subject 屬性進行編碼。An Encoding that was used to encode the Subject property.

範例

下列程式碼範例將示範如何SubjectEncoding設定屬性。The following code example demonstrates setting the SubjectEncoding property.

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

備註

如果郵件代理程式對SubjectEncodingUnicode有困難, 請使用UTF8If a mail agent has difficulty with a SubjectEncoding of Unicode, use UTF8.

適用於

另請參閱