31.3 ADD_ATTACHMENT Procedure Signature 2

This procedure adds an attachment of type CLOB to an outbound email message. To add multiple attachments to a single email, APEX_MAIL.ADD_ATTACHMENT can be called repeatedly for a single email message.

Syntax

APEX_MAIL.ADD_ATTACHMENT(
    p_mail_id                   IN    NUMBER,
    p_attachment                IN    CLOB,
    p_filename                  IN    VARCHAR2,
    p_mime_type                 IN    VARCHAR2);

Parameters

Table 31-2 ADD_ATTACHMENT Parameters

Parameter Description

p_mail_id

The numeric ID associated with the email. This is the numeric identifier returned from the call to APEX_MAIL.SEND to compose the email body.

p_attachment

A CLOB variable containing the text content to be attached to the email message.

p_filename

The filename associated with the email attachment.

p_mime_type

A valid MIME type (or Internet media type) to associate with the email attachment.

Examples

The following example demonstrates how to attached a CLOB-based attachment to an outbound email message.

DECLARE
	l_id NUMBER;
	l_clob CLOB := 'Value1,Value2,Value3,42';
BEGIN
	l_id := APEX_MAIL.SEND(
		p_to => 'fred@flintstone.com',
		p_from => 'barney@rubble.com',
		p_subj => 'APEX_MAIL with a text attachment',
		p_body => 'Please review the attachment.',
		p_body_html => '<b>Please</b> review the attachment');

	APEX_MAIL.ADD_ATTACHMENT(
		p_mail_id => l_id,
		p_attachment => l_clob,
		p_filename => 'data.csv',
		p_mime_type => 'text/csv');

	COMMIT;
END;
/