Condividi tramite


MailMessage.SubjectEncoding Proprietà

Definizione

Ottiene o imposta la codifica usata per il contenuto dell'oggetto di questo messaggio di posta elettronica.

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

Valore della proprietà

Classe Encoding utilizzata per codificare la proprietà Subject.

Esempio

Nell'esempio di codice seguente viene illustrata l'impostazione della SubjectEncoding proprietà.

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

Commenti

Se un agente di posta elettronica ha difficoltà con un SubjectEncoding oggetto di Unicode, usare UTF8.

Si applica a

Vedi anche