Partager via


MailAddress.Host Propriété

Définition

Obtient la partie hôte de l'adresse spécifiée quand cette instance a été créée.

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

Valeur de propriété

String qui contient le nom de l’ordinateur hôte qui accepte le courrier électronique pour la User propriété .

Exemples

L’exemple de code suivant affiche la destination d’un e-mail.

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

Remarques

Dans une adresse e-mail classique, la chaîne d’hôte inclut toutes les informations qui suivent le signe «@ ». Par exemple, dans "tsmith@contoso.com", l’hôte est "contoso.com".

S’applique à