Qore MailMessage Module Reference  1.3.2
MailMessage::Attachment Class Reference

class representing a MIME Attachment for the Message More...

Inheritance diagram for MailMessage::Attachment:

Public Member Methods

 constructor (string name, string mime, data data, string enc=EncBase64, *hash< auto > hdr)
 creates an Attachment object for a Message object More...
 
- Public Member Methods inherited from MailMessage::Part
 add (MultiPartMixedMessage mpm)
 adds itself to a multipart/mixed message
 
data getData ()
 returns the data of the Part
 
*hash< auto > getHeaders ()
 returns any headers for the Part
 
string getMime ()
 returns the mime type of the Part
 
string getName ()
 returns the name of the Part
 
string getTransferEncoding ()
 returns the transfer encoding of the Part
 

Detailed Description

class representing a MIME Attachment for the Message

this class wraps all the data for the attachment, including:

  • the attachment's name; ie the file name which will be shown
  • the mime type of the Attachment (ex: MimeTypeJpeg ie "image/jpeg")
  • the data for the attachment; either binary object or as a string
  • the encoding type for the attachment
Example:
File f();
f.open2("file.jpg");
Attachment att("file.jpg", MimeTypeJpeg, f.readBinary(-1));
f.close();
msg.attach(att);

Member Function Documentation

◆ constructor()

MailMessage::Attachment::constructor ( string  name,
string  mime,
data  data,
string  enc = EncBase64,
*hash< auto >  hdr 
)

creates an Attachment object for a Message object

Parameters
namethe name of the attachment to be displayed in the message, normally a file name without any path
mimethe mime type for the message
datathe attachment data itself
encthe encoding type for the message (see Message Encodings for possible values)
hdroptional headers for the MIME part for the attachment
Exceptions
UNKNOWN-ENCODINGthe message encoding value passed is unknown/unimplemented
INVALID-ENCODINGthe encoding given cannot be used with data given