EM_ADD_ATTACHMENT Function
Purpose
Adds an attachment to the email from the supplied content. The size of the attachment is limited by the size of the memory available to the user.
Returns TRUE or FALSE.
Syntax
EM_ADD_ATTACHMENT(content, filename-data, attachment-type)
Syntax elements
content The data to be attached as a file or an in-line attachment. It can contain either ASCII or binary data.
filename-data A dynamic array defining the details of the filename to use for the attachment.
Attribute |
Name |
Description |
---|---|---|
1 |
FILENAME |
The name to be given to the file as it appears attached to or embedded in the email. |
2 |
ALT TEXT |
This contains the text to be used if the content cannot be displayed. |
3 |
MIME TYPE |
An optional mime type to use in place of the one that could be derived from the file name extension. |
attachment-type Flag to indicate the type of attachment. This can be one of two values:
-
EM_CONTENT_ATTACHED
The content is to appear as a file attached to the email.
-
EM_CONTENT_INLINE
The content is to appear embedded in the email. For example, as an image in the HTML section of the email.
Returns
EM_ADD_ATTACHMENT returns TRUE if successful or FALSE if unsuccessful.
If FALSE, the details of the failure to using the configuration can be found by inspecting the error number held in the common variable EM_ERROR_DETAILS.
If TRUE, and the attachment is to be included in-line, the named common EM_COMMON variable EM_LINK_DATA contains a formatted HTML <img> tag to represent this attachment. This is structured as:
<img src="cid:identifier" alt="alternative text" />
where identifier is a random string used to identify the attachment and alternative text is the text to displayed if the image cannot be shown in the client. The programmer must add this link to the body of email where appropriate. The next call to EM_ADD_ATTACHMENT will result in EM_LINK_DATA being overwritten so the programmer must use the original value or save it before calling EM_ADD_ATTACHMENT again.
Comments
You must include the item #EM_INCLUDES
in all programs that use the Email API functions; for example, you could add the line
INCLUDE #EM_INCLUDES FROM /SYSFILES/SYS.BASLIB
at the start of the program, or create an item to be automatically included that contains this line.