語言

MailAddress.Host 屬性

定義

取得建立此實例時指定的主機位址部分。

public:
 property System::String ^ Host { System::String ^ get(); };
public string Host { get; }
member this.Host : string
Public ReadOnly Property Host As String

屬性值

String A 包含接受該物業電子郵件User的主機名稱。

範例

以下程式碼範例顯示電子郵件的目的地。

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"。

適用於