INetMailAddressCollection.AddString

Syntax

AddString(Value: String);

Parameters

Value - email address that must be added to the collection.

NOTE. Email address format must correspond with the address format used in email 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@mail.ru.

Description

The AddString method adds the email address passed as a text string to the collection.

Example

Sub Main;

Var

From_, To_: INetMailAddress;

CopyTo: INetMailAddressCollection;

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 with copies";

CopyTo := Message.CC;

CopyTo.AddString("user1@mail.ru");

CopyTo.AddString("user2@mail.ru");

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

Client.Send(Message);

End Sub Main;

After executing the example the message is sent via the specified mail server. The message copy is sent to two addresses: user1@mail.ru and user2@mail.ru.

See also:

INetMailAddressCollection