语言

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 包含接受属性电子邮件 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"

适用于