below is the code snippet of the visualoforce email template.

<messaging:attachment renderAs="PDF" filename="yourCases.pdf">
        This pdf data I want in the apex as attachment to store.

I Want this pdf attachmet in apex which I want to store as attachment on one object.

1 Answer 1


So I won't get the standard solution to get the attachment from visualforce template to store on record's attachment.

So alternate way which I used is, we can create one visualforce component in which we can put the code we want in pdf. And use the same visualforce component in visualforce email template.

Then make a visualforce page in which use that visualforce component. and finally to store the pdf as attchment use getContentAspdf() method.

So whenever you make any changes in pdf i.e. visualforce component then it will reflect in both email template as well as attachment which we stored by getContent() method

so for my case I did the same & working as expected.

You must log in to answer this question.

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