INetSmtpClient.Send

Syntax

Send(Message: INetMailMessage);

Parameters

Message. Email message that must be sent.

Description

The Send method sends an email message.

Comments

A message is sent via the mail server specified on initializing in the NetSmtpClient.CreateWithHost or NetSmtpClient.CreateWithHostAndPort constructor, or to the server determined in the Host property. Messages are sent taking into account the parameters set in the Port and Timeout properties.

Example

Sub SendMailMessage;
Var
    From_, To_: INetMailAddress;
    Message: INetMailMessage;
    Client: INetSmtpClient;
    Credential: INetNetworkCredential;
Begin
    From_ := New NetMailAddress.Create("ivanov@server.ru");
    To_ := New NetMailAddress.Create("petrov@mail.ru");
    Message := New NetMailMessage.CreateWithFromAndTo(From_, To_);
    Message.Subject := "Test message";
    Message.Body := "Message text";
    Client := New NetSmtpClient.CreateWithHost("example.server.ru");
    Credential := New NetNetworkCredential.Create("user""password""work");
    Client.ThisHostCredentials("") := Credential;
    Client.Send(Message);
End Sub SendMailMessage;

The specified procedure enables the user to send emails via the specified mail server. The specified credentials are used for authorization at the mail server.

See also:

INetSmtpClient