NetSmtpClient.CreateWithHostAndPort

Syntax

CreateWithHostAndPort(Host: String; Port: Integer);

Parameters

Host is the mail server name or the IP address.

Port - the port, that provides the access to mail server.

Description

The CreateWithHostAndPort designer creates an object, that provides email messages sending.

Comments

The mail server name or the IP address and the port, that provides message sending; the data is passed by means of the Host and the Port parameters respectively. The method is used if for some reason the message can not be sent through the mail server standard port.

Example

Sub SendMailMessage(Server: String; Port: Integer);

Var

From_, To_: INetMailAddress;

Message: INetMailMessage;

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

Message.Body := "Letter body";

Client := New NetSmtpClient.CreateWithHost("example.server.ru", 8080);

Client.Send(Message);

End Sub SendMailMessage;

The procedure can be used for sending email messages via a specified mail server. The mail server name or IP address and the port, through which the message is sent are specified in the Server and Port procedure parameters.

See also:

NetSmtpClient