NetMailMessage.CreateWithFromAndTo

Syntax

CreateWithFromAndTo(From_: INetMailAddress; To_: INetMailAddress);

Parameters

From_ - sender email address.

To_ - recipient email address.

Description

The CreateWithFromAndTo constructor creates an email message. The sender address and the recipient address are passed by means of the From_ and the To_ parameters respectively.

Example

Sub Main;

Var

From_, To_: INetMailAddress;

Message: INetMailMessage;

Attach: INetAttachment;

Client: INetSmtpClient;

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

Client.Send(Message);

End Sub Main;

After executing the example a message is sent via the specified mail server. The message is created considering the sender and the recipient addresses without any copies sending.

See also:

NetMailMessage