Send(Message: INetMailMessage);
Message. Electronic mail message that is required to send.
The Send method sends an email message.
A message is sent via the mail server specified on initializing in the NetSmtpClient.CreateWithHost or NetSmtpClient.CreateWithHostAndPort designer, or to the server determined in the Host property. Messages are sent taking into account the parameters set in the Port and Timeout properties.
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 letter";
Message.Body := "Letter text";
Client := New NetSmtpClient.CreateWithHost("example.server.ru");
Credential := New NetNetworkCredential.Create("user", "password", "work");
Client.ThisHostCredentials("") := Credential;
Client.Send(Message);
End Sub SendMailMessage;
This procedure enables the user to send emails via the specified mail server. The specified account credentials will be used for authorization in the mail server.
See also: