Name

Attachments — Adding attachments to messages.

Attachments

Attachments are used to send a binary file with a email message. There are a few different attachments types.

ATTACH_BY_VALUE, the attachment data is stored within the message object.
ATTACH_EMBEDDED_MSG, the attachment is stored as a message object within the message object.
ATTACH_BY_REFERENCE, ATTACH_BY_REF_RESOLVE and ATTACH_BY_REF_ONLY are references to a file by name. Since the PHP code runs on the server, these types are unsupported.

All of these types use different ways to store the name and to store the attachement data. with mapi_message_getattachmenttable() the table with all the attachments can be read from the message. Every row in this table has a property PR_ATTACH_METHOD which defines with which method the attachment was stored (see the values above). The property to read from an attachment or the function to call depends on the method an attachment has:

NO_ATTACHMENT

The attachment has just been created.

ATTACH_BY_VALUE

The PR_ATTACH_FILENAME and PR_ATTACH_LONG_FILENAME contains the name of the attachment. When the attachment is opened with mapi_message_openattach() the data can be read with mapi_attach_openbin().

ATTACH_EMBEDDED_MSG

The PR_DISPLAY_NAME contains the name of the attachment (This is mostly the PR_SUBJECT of the message that has been attached). With mapi_attach_openobj() the attachment can be read from the message. This function returns a message object.

ATTACH_BY_REFERENCE, ATTACH_BY_REF_RESOLVE and ATTACH_BY_REF_ONLY

These types are unsupported and should never be used.

When created, all attachment objects have an initial PR_ATTACH_METHOD value of NO_ATTACHMENT. Client applications and service providers are only required to support the attachment method represented by the ATTACH_BY_VALUE value. The other attachment methods are optional.

The message store does not enforce any consistency between the value of PR_ATTACH_METHOD and the values of the other attachment properties.