MailAddress.User Propriedade

Definição

Obtém a informação do utilizador a partir do endereço especificado quando esta instância foi criada.

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

Valor de Propriedade

A String que contém a parte do nome de utilizador do Addressarquivo .

Exemplos

O seguinte exemplo de código mostra o destino de uma mensagem de email.

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

Observações

Num endereço de email típico, a string de utilizador inclui toda a informação anterior ao sinal "@". Por exemplo, em "tsmith@contoso.com", o utilizador é "tsmith".

Aplica-se a