1

below is the code snippet of the visualoforce email template.

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

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

0

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.