Is there a way, out of the box Salesforce functionality, Lightning Experience, to send somehow an e-mail with an attachment (word or pdf) and merged fields? More specifically, my requirement is:

  1. I am at case record and has relationship with a custom Objcet (Subscription)
  2. I need from case record (i have already selected the lookup record from Subscription entity) to send an e-mail with an attached document with filled in the Subscription Number (custom field on subscription) and account's data (name, VAT number etc).

Any suggestions?

  • But where is the document? Is it attached to the case or the subscription record? Oct 23, 2020 at 20:03
  • The document is in the Files Library within Salesforce Oct 23, 2020 at 20:07
  • 1
    Out of the box, your only shot is to stick all the merge logic into a VF page and then render it as a PDF. You can do it in Apex as the referenced answer shows but it might run afoul of the governor limits, depends on the size of the page. As another option, there are 3rd party apps on AppExchange that do this too. The best architecture for this is serverless, IMO. Salesforce announced a serverless product (fka Evergreen, now Functions) but it's far from being GA. Heroku, AWS, etc.. are all good options for serverless with plenty of OSS/etc libraries to handle mail merge with PDF.
    – identigral
    Oct 23, 2020 at 20:56
  • The Visualforce rendering is relevant, but OP did not specify whether or not this is an automation. If it is not, then an email template with merge fields using related records from the case would be enough. Oct 23, 2020 at 21:15
  • @Renato Oliveira Fair point, it's not clear if he meant merge the fields into the doc, modifying the doc content or merge into email with the doc unmodified. OP - please edit your question to clarify.
    – identigral
    Oct 23, 2020 at 21:51


Browse other questions tagged .