Fuego.Net : MailAttachment

The MailAttachment component represents a file attached to an email message. The component is used to read attachments in an incoming email and to add attachments to an outgoing email.

A MailAttachment can be created from an existing file or from a Binary object.

The attachments attribute of the Mail component is an array of MailAttachment objects.

Example 1

The following example creates an email with two file attachments:

Mail.recipient = "example_recipient@oracle.com"
Mail.from = "example_sender@oracle.com"
Mail.subject = "Example Message"
Mail.message = "This is an example email message"

Mail.attachments[] = MailAttachment(fileName : "C:\\fife_to_attach_1.bin")
Mail.attachments[] = MailAttachment(fileName : "C:\\fife_to_attach_2.bin")

Example 2

The following example reads the attachments of an email and saves them to the filesystem:

mail as Mail
// ...

for each attachment in mail.attachments do 

  BinaryFile.writeFromBinaryTo(data : attachment.data,
        name : "c:\\attachments\"+attachment.name,
        append : false) 
end 
Related reference
Fuego.Net : Mail