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
属性值
示例
下面的代码示例显示电子邮件的目标。
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"
,用户为 "tsmith"
。