MailAddress.User 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
從建立此實例時指定的位址取得使用者資訊。
public:
property System::String ^ User { System::String ^ get(); };
public string User { get; }
member this.User : string
Public ReadOnly Property User As String
屬性值
範例
以下程式碼範例顯示電子郵件的目的地。
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"中,使用者為 "tsmith"。