CurlMailAddress.CreateWithName

Syntax

CreateWithName(Address: String; DisplayName: String);

Parameters

Address. Email address.

NOTE. Email address format must correspond with the address format used in emailing organization based on the SMTP and POP protocols and must be of the following form: address@mail_domain where address - recipient identifier, and mail_domain - mail server domain name. Example: user@samplemail.ru.

DisplayName. The name displayed instead of address on sending emails.

Description

The CreateWithName constructor creates an instance of email address with name displayed instead of the address on sending email messages.

Comments

The name specified in the DisplayName parameter will be displayed in various email clients as an email sender name.

Example

Add a link to the Net system assembly.

Sub UserProc;
Var
    From_, To_: INetMailAddress;
    Message: INetMailMessage;
    Client: INetSmtpClient;
Begin
    From_ := 
New CurlMailAddress.CreateWithName("ivanov@server.ru""Ivan Ivanov");
    To_ := 
New CurlMailAddress.CreateWithName("petrov@mail.ru""Petrov");
    Message := 
New CurlMailMessage.CreateWithFromAndTo(From_, To_);
    Message.Subject := 
"Test message";
    Message.Body := 
"Message text is placed here";
    Client := 
New CurlSmtpClient.CreateWithHost("example.server.ru");
    Client.Send(Message);
End Sub UserProc;

After executing the example the message is sent via the specified mail server. For message sending the two email addresses with the name, displayed instead of the email address, are created: From_ - sender address (the email address that must be registered at the mail server); To_ - the address, to which the message must be sent (if this email does not exist, the corresponding notification is sent to the first email).

This example can be started for execution in Linux family operating systems.

See also:

CurlMailAddress