Sending email attachments through an activity
Share context-rich information or make your messages more appealing by automatically attaching files to outbound email.
Depending on your business requirements, you can configure an activity to add attachments that the email client displays in the Attachments section, or you can send inline attachments that are embedded in the email body.
For example, marketers often attach image files to professional email to incentivize prospective customers to open the message or to better demonstrate the value of the offer. Other scenarios might involve an online retailer who sends the customer an email with the transaction summary that includes a PDF invoice.
To complete this task, you select an activity that you want to configure for sending email attachments. Then, in that activity, you create and populate the .pxResults attachment page (for example, InlineAttachmentPage.pxResults) by using the pzInsKey object handle of the attachment. Finally, you call an automation that references the attachment page that you created.
- In the header of Dev Studio, search for and open the activity rule that you want to edit.
- Click the Pages & Classes tab.
- Click Add item and then populate the Page
name and Class fields for the following
pages:
Page Name Class Sample value <attachment_page_name> Code-Pega-List InlineAttachmentPage <attachment_page_name>.pxResults Embed-ContentSource-LinkAttachment InlineAttachmentPage.pxResults - Click the Steps tab.
- Click Add step and then populate the
Method and Step page fields
for the following activity steps:
Method Step Page Sample value Page-New The name of the attachment page that you created in step 3. InlineAttachmentPage Page-New <attachment_page_name>.pxResults(1) InlineAttachmentPage.pxResults(1) Property-Set <attachment_page_name>.pxResults(1) InlineAttachmentPage.pxResults(1) - Optional: To provide more details about the step, in the Description field for each new step, enter a short step summary.
- Drag the new steps in the target positions within the activity, as shown in the following figure:
- Set the attachment properties:
- In the Property-Set activity step that you created in step 5, expand the Method Parameters section.
- Click Add item and then populate the
PropertiesName and
PropertiesValue fields for the following
properties:
PropertiesName PropertiesValue Additional information .pzInsKey Sample value:LINK-ATTACHMENT PEGASOCIAL-DOCUMENT DOC-9848022338!20190327T194337.398 GMT The object handle must have the following format: CLASSNAME CLASSKEY ! NAME #YYYYMMDD T HHMMSSTTTTMMM GMT .pyContentTransferEncoding Sample value: "Base64" Provide the attachment encoding type. .pyContentType Sample values: - "" (default)
- "application/pdf" for a PDF reader (for example, Acrobat Reader)
- "application/ms-tnef" for Microsoft Outlook or Microsoft Exchange
(Optional) Populate this property to communicate the attachment extension to the email client. This way the client can select the appropriate application to open the attached file. .pyContentID Sample value: param.ContentID Set this parameter for inline attachments only. This parameter is the header for referencing the attachment from the message body.
You can get this ID by inspecting the body of the email HTML markup. For example, if the body contains the <IMG SRC="ContentID: PegaLogo"> tag, the email client expects an attached image whose ContentID value is PegaLogo. The email client displays the image in place of the <IMG SRC="ContentID: PegaLogo"> tag while rendering the HTML body of the email.
.pxObjClass "Embed-ContentSource-LinkAttachment" Set this object class for any attachment type.
- Add a step for creating and sending email through the
Call-Automation method:
- On the Steps tab, click Add step.
- In the Method field, enter Call-Automation.
- Expand the Method Parameters section.
- In the Resource field, select Email message.
- In the Automation field, select Create and send email.
- In the Inputs section of the
Call-Automation step, specify the attachment type that
you want to add to the message:
- For resources that you want to embed in the email Attachments section, in the Attachments field, enter <attachment_page_name>.pxResults.
- For attachments that you want to embed in the email HTML body, in the Embedded Content field, enter <attachment_page_name>.pxResults.
- Save the activity.
Previous topic Best practices for optimizing email listener performance Next topic Ensuring messages are processed before switching your email protocol to Microsoft Graph