MailAddress.User プロパティ

定義

このインスタンスが作成されたときに指定されたアドレスからユーザー情報を取得します。Gets the user information from the address specified when this instance was created.

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

プロパティ値

String

String のユーザー名の部分を格納している AddressA String that contains the user name portion of the Address.

次のコード例では、電子メールメッセージの送信先を表示します。The following code example displays the destination of an email message.

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);
}

注釈

一般的な電子メールアドレスでは、"" という記号の前にあるすべての情報がユーザー文字列に含まれ @ ます。In a typical email address, the user string includes all information preceding the "@" sign. たとえば、で "tsmith@contoso.com" は、ユーザーは "tsmith" です。For example, in "tsmith@contoso.com", the user is "tsmith".

適用対象