Reply
Trusted Contributor
vishal@force
Posts: 427
0

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-te...

 

Any ideas/solutions?  

Vishal, Certified Developer and Administrator
Kudos a post if it helps, mark it as solution if it solves.
http://exploretheforce.blogspot.in
Regular Contributor
Jean-Noel
Posts: 27
0

Re: Dynamic Content in Attachment?

Why not using a VF email template ?

You could have a PDF as attachment.

Trusted Contributor
vishal@force
Posts: 427
0

Re: Dynamic Content in Attachment?

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

Vishal, Certified Developer and Administrator
Kudos a post if it helps, mark it as solution if it solves.
http://exploretheforce.blogspot.in
Regular Contributor
Jean-Noel
Posts: 27
0

Re: Dynamic Content in Attachment?

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.