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
JeriMorrisJeriMorris 

VF Email Template with a PDF Attachment

This question is similar to VF Email Template with a PNG Attachment, but for PDF attachments.

 

I need to create a VF Email template that creates an email message with a PDF attachment. The PDF comes from an Attachment to the record that is the relatedToType for the email message. In other words, on the RelatedTo object, I've created an Attachment record whose body is a PDF. That's the PDF that I want to attach to the email message.

 

I have to use workflow to send the email -- I can't use Apex, so I can't use Apex's Messaging classes to contruct the email attachment. 

 

I don't want to send a link to the Attachment record in Salesforce, I want the PDF to be attached to the email.

 

I'm using <messaging:attachment>. I'm pretty sure I don't want to use renderAs="PDF", because the Attachment record already is in PDF format -- I don't need Salesforce to render it that way. The body of messaging:attachment is a custom component that uses a controller to find the Attachment record. I've tried several different ways of rendering the Attachment's Body in the custom component, with no success. Do you have any suggestions for how I might do it?

 

Thanks!