NetSmtpClient.CreateWithHostAndPort

Syntax

CreateWithHostAndPort(Host: String; Port: Integer);

Parameters

Host. Mail server name or IP address.

Port. Port, via which the system accesses mail server.

Description

The CreateWithHostAndPort constructor creates an object that provides for email message sending.

Comments

The mail server name or the IP address and the port that provides message sending are passed by the Host and the Port parameters respectively. This method is used if for some reason the message cannot 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 message";

Message.Body := "Message text";

Client := New NetSmtpClient.CreateWithHostAndPort(Server, Port);

Client.Send(Message);

End Sub SendMailMessage;

This procedure can be used for sending email messages via the 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