function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Phuc Nguyen 18Phuc Nguyen 18 

Dynamically add attachment to SF email template

Hello All,
Currently I am attaching a PDF that is dynamically generated and atatching it to an email.  All done via controller.
The email itself has become more complicated and the users want to be able to update the email as needed so I need to utilize a SF email template instead of my email controller.  Is this possible?  Use SF email tempalte and dynamically attach a file?  This file is not attched to the record.  I am currently rendering it as a pdf and attaching it before I send.  
Thank you,
P
Best Answer chosen by Phuc Nguyen 18
Vishwajeet kumarVishwajeet kumar
Hello,
Try Visualforce Email Templates, it can provide you ability to attachment files using components. However, it will also require to create Email  template itself using Html/Visualforce code. Checkout this link (https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_email_templates_attachments.htm) .

Thanks

All Answers

Vishwajeet kumarVishwajeet kumar
Hello,
Try Visualforce Email Templates, it can provide you ability to attachment files using components. However, it will also require to create Email  template itself using Html/Visualforce code. Checkout this link (https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_email_templates_attachments.htm) .

Thanks
This was selected as the best answer
Phuc Nguyen 18Phuc Nguyen 18
Thanks for the reply Vishwajeet.  I was hoping to be able to use the standard SF template so that I do not have to deal with styling/formatting.  Is it possible to use the standard SF template and add an attachment dynamically?
thank you,
P