Skip to main content


         This documentation site is for previous versions. Visit our new documentation site for current releases.      
 

Sending email attachments through an activity

Updated on April 6, 2022

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.

Before you begin: Obtain the pzInsKey object handle of the content that you want to send as an attachment or note the parameter that stores the pzInsKey value.
Tip: You can retrieve the attachment pzInskey object handle in multiple ways. For example, you can browse the Link-Attachment class or you can inspect the case-related content in the Clipboard tool, as shown in the following figure:
Browsing clipboard pages for attachment object handle
The Clipboard tool contains references to the attachment object handle.

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.

  1. In the header of Dev Studio, search for and open the activity rule that you want to edit.
  2. Click the Pages & Classes tab.
  3. Click Add item and then populate the Page name and Class fields for the following pages:
    Page NameClassSample value
    <attachment_page_name>Code-Pega-ListInlineAttachmentPage
    Note: You can assign a custom name to the attachment page.
    <attachment_page_name>.pxResultsEmbed-ContentSource-LinkAttachmentInlineAttachmentPage.pxResults
  4. Click the Steps tab.
  5. Click Add step and then populate the Method and Step page fields for the following activity steps:
    MethodStep PageSample value
    Page-NewThe 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)
  6. Optional: To provide more details about the step, in the Description field for each new step, enter a short step summary.
  7. Drag the new steps in the target positions within the activity, as shown in the following figure:
    Creating a .pxResults page for attachment content
    Activity steps for creating and setting the AttachmentPage.pxResults page.
  8. Set the attachment properties:
    1. In the Property-Set activity step that you created in step 5, expand the Method Parameters section.
    2. Click Add item and then populate the PropertiesName and PropertiesValue fields for the following properties:
      PropertiesNamePropertiesValueAdditional information
      .pzInsKeySample value:LINK-ATTACHMENT PEGASOCIAL-DOCUMENT DOC-9848022338!20190327T194337.398 GMTThe object handle must have the following format: CLASSNAME CLASSKEY ! NAME #YYYYMMDD T HHMMSSTTTTMMM GMT
      .pyContentTransferEncodingSample value: "Base64"Provide the attachment encoding type.
      .pyContentTypeSample 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.
      .pyContentIDSample 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.
    For example: The following figure shows sample attachment property values within the .pxResults page:
    Setting attachment properties
    A sample configuration of the pxResults page.
    Tip: You can send multiple attachments in a single message by creating and setting additional pxResults pages, for example, InlineAttachmentPage.pxResults(2), InlineAttachmentPage.pxResults(3), and so on.
  9. Add a step for creating and sending email through the Call-Automation method:
    1. On the Steps tab, click Add step.
    2. In the Method field, enter Call-Automation.
    3. Expand the Method Parameters section.
    4. In the Resource field, select Email message.
    5. In the Automation field, select Create and send email.
  10. 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.
    For example: The following figure shows the Call-Automation step when you embed an inline attachment:
    Configuring attachment placement
    The Call-Automation step, with a configured activity to place the content in the Attachments section or in the email body.
  11. Save the activity.
What to do next: Reference this activity in your application whenever you need to send email messages with attached content, for example, in email responses, as part of a Service Email rule. For more information, see Creating a Service Email rule.
  • Previous topic Best practices for optimizing email listener performance
  • Next topic Ensuring messages are processed before switching your email protocol to Microsoft Graph

Have a question? Get answers now.

Visit the Support Center to ask questions, engage in discussions, share ideas, and help others.

Did you find this content helpful?

Want to help us improve this content?

We'd prefer it if you saw us at our best.

Pega.com is not optimized for Internet Explorer. For the optimal experience, please use:

Close Deprecation Notice
Contact us