INetAttachmentCollection.Add

Syntax

Add(Value: INetAttachment);

Parameters

Value - attachment that must be added to the collection.

Description

The Add method adds an attachment to the collection.

Example

Sub Main;

Var

From_, To_: INetMailAddress;

Attach: INetAttachment;

AttachCollect: INetAttachmentCollection;

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 is specified here";

Attach := New NetAttachment.Create("c:\image01.jpg");

AttachCollect := Message.Attachments;

AttachCollect.Add(Attach);

Attach := New NetAttachment.Create("c: \image02.jpg");

AttachCollect.Add(Attach);

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. Two files named image01.jpg and image02.jpg are added to the message as attachments.

See also:

INetAttachmentCollection