INetAttachmentCollection.Add

Syntax

Add(Value: INetAttachment);

Parameters

Value. The attachment that should be added to the collection.

Description

The Add method adds an attachment to the collection.

Example

Executing the example requires that the file system contains the image files: C:\image01.jpg and C:\image02.jpg.

Add a link to the Net system assembly.

Sub UserProc;
Var
    From_, To_: INetMailAddress;
    Attach: INetAttachment;
    AttachCollect: INetAttachmentCollection;
    Message: INetMailMessage;
    Client: INetSmtpClient;
Begin
    From_ := New CurlMailAddress.Create("ivanov@server.ru");
    To_ := New CurlMailAddress.Create("petrov@mail.ru");
    Message := New CurlMailMessage.CreateWithFromAndTo(From_, To_);
    Message.Subject := "Test message";
    Message.Body := "Message text is placed here";
    Attach := New CurlAttachment.Create("c:\image01.jpg");
    AttachCollect := Message.Attachments;
    AttachCollect.Add(Attach);
    Attach := New CurlAttachment.Create("c:\image02.jpg");
    AttachCollect.Add(Attach);
    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. Two files named image01.jpg and image02.jpg are added to this message as attachments.

See also:

INetAttachmentCollection