+ Start a Discussion
vishal@forcevishal@force 

Dynamic Content in Attachment?

Hello people,

 

We have a requirement where we have to send email  on submission of a form. The email should have an attachment which has dynamic content based on the record. I couldn't find any OOTB feature that will allow me to do so. But if I missed something here, please advice.

 

Coming to doing this using Apex, in my submit code (it's just a simple button click), I am inserting contacts and then using a visualforce page which is rendered as pdf to give me a blob which I'm then attaching to my email. The visualforce page has StandardController, so passing the id would give me record-specific data. 

 

However, the issue I am facing here is that when the .getContent() method is called from my code, I get an "unable to retrieve object" error. Is it that since the record has just been inserted and immediately I'm using it's standard controller?

It is the same issue here too :
http://boards.developerforce.com/t5/Apex-Code-Development/Unable-to-retrieve-object-PDF-Email-Not-testing/m-p/547369#M99719

 

Any ideas/solutions?  

Jean-NoelJean-Noel

Why not using a VF email template ?

You could have a PDF as attachment.

vishal@forcevishal@force

But I can have a single attachment for all emails, so it will not let me have dynamic data for each email

Jean-NoelJean-Noel

Hello,

 

With a VF email template, you have dynamic data, like a registration form populated as a PDF attachment.

You can also have the same file as attachment.