Add(Value: INetMailAddress);
Value is the email address that needs to be added to the collection.
The Add method adds the email address to the collection.
Sub Main;
Var
Addr, 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 letter";
Message.Body := "Letter copies";
CopyTo := Message.CC;
Addr := New NetMailAddress.CreateWithName("user1@mail.ru", "User");
CopyTo.Add(Addr);
Addr := New NetMailAddress.Create("user2@mail.ru");
CopyTo.Add(Addr);
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. The letter copy is sent to two addresses: user1@mail.ru and user2@mail.ru.
See also: