AddAttachment

Syntax 1: Adding a file as an attachment

Description

Adds an existing file as an attachment to the email message.

Applies to

MimeMessage object

Syntax

mimemessage.AddAttachment(string attachment)

Argument

Description

mimemessage

A MimeMessage object identifying the email message in which you want to add attachment.

attachment

A string that specifies the full path or relative path to an existing file on disk. The file is read from the specified location and attached to the email message.


Return value

Integer.

Returns 1 if it succeeds and -1 if an error occurs. If any argument's value is null, the method returns null.

Examples

The following example adds c:\image\test01.png and test02.docx as attachments when sending an email.

lnv_SmtpClient.Message.AddAttachment("c:\image\test01.png")
lnv_SmtpClient.Message.AddAttachment("test02.docx")

See also

AddBcc

AddCc

AddLinkedResource

AddRecipient

AddReplyTo

GetSender

Reset

SetSender

Syntax 2: Adding a binary value as an attachment

Description

Adds an attachment to the email message using the binary data that are generated or retrieved dynamically (e.g. from a database blob field).

Applies to

MimeMessage object

Syntax

mimemessage.AddAttachment (string filename, blob fileblob)

Argument

Description

mimemessage

A MimeMessage object identifying the email message in which you want to add attachment.

filename

The name of the attached file to be displayed in the email, for example, "report.pdf". The file does not need to exist on disk; the file content will be taken from fileblob.

fileblob

A blob value containing the binary content of the file, which will be sent as the actual attachment content.


Return value

Integer

Returns 1 if it succeeds and -1 if failure or if filename or fileblob is empty. If any argument's value is null, the method returns null.

Examples

The following example retrieves data from a database and then sends the data as attached file test02.docx.

// Example: attach file content retrieved from a database
Blob lblob
SELECT attachment_blob INTO :lblob FROM my_table WHERE id = 1;
lnv_SmtpClient.Message.AddAttachment("test02.docx", lblob)

See also

AddBcc

AddCc

AddLinkedResource

AddRecipient

AddReplyTo

GetSender

Reset

SetSender