CreateWithName(Address: String; DisplayName: String);
Address. Email address.
NOTE. The email address format must conform to the address format used in emailing organization based on the SMTP and POP protocols and must be of the following formaddress@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.
The CreateWithName designer creates the email address object with a name displayed instead of this email address on sending emails.
The name specified in the DisplayName parameter will be displayed in various email clients as an email sender name.
Sub Main;
Var
From_, To_: INetMailAddress;
Message: INetMailMessage;
Client: INetSmtpClient;
Begin
From_ := New NetMailAddress.CreateWithName("ivanov@server.ru", "Ivan Ivanov");
To_ := New NetMailAddress.CreateWithName("petrov@mail.ru", "Petrov");
Message := New NetMailMessage.CreateWithFromAndTo(From_, To_);
Message.Subject := "Test letter";
Message.Body := "The letter text is specified here";
Client := New NetSmtpClient.CreateWithHost("example.server.ru");
Client.Send(Message);
End Sub Main;
After executing the example a letter is sent via the specified mail server. For the message sending the two following email addresses with the name, displayed instead of the email address, are created: From_ - the sender address (the email address that has to be registered on the mail server); To_ - the address to which the letter needs to be sent (if this address does not exist, the corresponding notification is sent to the first address).
See also: