CurlAttachment.Create

Syntax

Create(FileName: String);

Parameters

FileName. Path and name of the file, which must be used as attachment to email message.

Description

The Create constructor creates an email attachment.

Example

Executing the example requires the C:\Image01.jpeg file.

Add a link to the Net system assembly:

Sub UserProc;
Var
    From_, To_: INetMailAddress;
    Message: INetMailMessage;
    Attach: INetAttachment;
    Client: INetSmtpClient;
    Credent: INetNetworkCredential;
Begin
    From_ := 
New CurlMailAddress.Create("user1@example.ru");
    To_ := 
New CurlMailAddress.Create("user2@example.ru");
    Message := 
New CurlMailMessage.CreateWithFromAndTo(From_, To_);
    Message.Subject := 
"Test message";
    Message.Body := 
"Message text";
    Attach := 
New CurlAttachment.Create("c:\Image01.jpeg");
    Message.Attachments.Add(Attach);
    Client := 
New CurlSmtpClient.CreateWithHost("example.server.ru");
    Credent := 
New CurlNetworkCredential.Create("user1""password""domain");
    Client.ThisHostCredentials(
"https") := Credent;
    Client.Send(Message);
End Sub UserProc;

After executing the example an email message with the topic "Test message" and the text "Message text" is sent from the mail address user1@example.ru to the mail address user2@example.ru. The Image01.jpeg file is attached to the message. The message is sent via the example.server.ru mail server working on HTTPS protocol. The specified credentials are used for authorization on mail server.

This example can be started for execution in Linux family operating systems.

See also:

CurlAttachment