MailAddress.Host 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
取得建立這個執行個體時所指定之地址的主機部分。
public:
property System::String ^ Host { System::String ^ get(); };
public string Host { get; }
member this.Host : string
Public ReadOnly Property Host As String
屬性值
String,其中包含接受屬性電子郵件User的主計算機名稱。
範例
下列程式代碼範例會顯示電子郵件訊息的目的地。
static void CreateTestMessage3()
{
MailAddress^ to = gcnew MailAddress( L"jane@contoso.com" );
MailAddress^ from = gcnew MailAddress( L"ben@contoso.com" );
MailMessage^ message = gcnew MailMessage( from,to );
message->Subject = L"Using the new SMTP client.";
message->Body = L"Using this new feature, you can send an email message from an application very easily.";
// Use the application or machine configuration to get the
// host, port, and credentials.
SmtpClient^ client = gcnew SmtpClient;
Console::WriteLine( L"Sending an email message to {0} at {1} by using the SMTP host {2}.", to->User, to->Host, client->Host );
client->Send( message );
}
public static void CreateTestMessage3()
{
MailAddress to = new MailAddress("jane@contoso.com");
MailAddress from = new MailAddress("ben@contoso.com");
MailMessage message = new MailMessage(from, to);
message.Subject = "Using the new SMTP client.";
message.Body = @"Using this new feature, you can send an email message from an application very easily.";
// Use the application or machine configuration to get the
// host, port, and credentials.
SmtpClient client = new SmtpClient();
Console.WriteLine("Sending an email message to {0} at {1} by using the SMTP host={2}.",
to.User, to.Host, client.Host);
client.Send(message);
}
備註
在一般電子郵件位址中,主機字串包含 「@
符號之後的所有資訊」。 例如,在中 "tsmith@contoso.com"
,主機為 "contoso.com"
。