I have a custom object with Files. The Files hold images. I am creating an email template and want the Files to embed in the email template. How do I even begin to go about that? I can't find anything online.

End State: Form submitted (through form assembly) into the custom object. Upon insert, a process builder is fired which triggers an email alert. The email alert grabs whatever and however many images are in the Files object for the record and embeds them be low the text of the email.

  • What's the end result/goal look like? Is there something special going on for whether a specific file goes on a specific type of template? You can just attach files to the template if it's something static. Oct 8, 2019 at 23:47
  • I just added to the description the End State.
    – paulK
    Oct 8, 2019 at 23:50

1 Answer 1


You can't really do what you'd want with typical email templates as they can only really display static images that you paste in or references to files that already exist. Since, in this case, the records/files will be created moments before (or be the trigger), it'll need to be able to dynamically pull them when the alert goes out. I can see one of two options:

  1. Using PB and email alert and Visualforce Email template Basically, the plan you had going on where the VF email template will handle the hard part which is getting the image from a file on the record.



The second link will be important. You'd essentially create a custom apex class that would pull the Attachment/file and then create a URL to access that file.

You'd have a custom component that just serves to display the image (if it needs to be displayed) using and passing in the url from the apex you built.

Then, you'd have a Visualforce email template that would include this component at whatever location you'd like around all the other text. You can access merge fields from the record and do normal things here as well (first document link).

  1. Complete Apex Solution

You could look to do this all in apex upon insert with separate methods for building the url to display in html, building the email body, and sending the email. However, whenever you get the chance to use the standard options (PB, email alerts, template), I'd say it's a better option for maintainability than going for completely custom. https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_classes_email_outbound_single.htm

  • Thanks for the info. This is what I was thinking as well. We may a slightly custom third party solution to get this to work (S-Docs). Much heavier lift on the Apex side.
    – paulK
    Oct 9, 2019 at 0:26
  • option 1 is the way I would do this.
    – cropredy
    Oct 9, 2019 at 1:21

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .