+ Start a Discussion

Adding the attachment in Pdf

Hi all, I have a vf template. it will render as pdf and able send the mail. I have a attachemnt with case object. i want to add this attachment to vf template. Can please help me.

You can try to add something like this to your vf template:

<messaging:attachment renderAs="PDF" filename="cases.pdf">
		<p>You can display your {!relatedTo.name} cases as a PDF:</p>
			<table border="0" >
				<th>Case Number</th><th>Origin</th>
				<th>Creator Email</th><th>Status</th>
			<apex:repeat var="cx" value="{!relatedTo.Cases}">
				<td><a href = 

Reference Link: https://www.salesforce.com/docs/developer/pages/Content/pages_email_templates_attachments.htm
Hi Yuchen,

whatever you have given that is like making case information as attachment and rendered as pdf. That we have already implemented. what my quetion is i have a case record with attachment(related list). i have a vf template with same like your code for rendering case information as a pdf. With this vf template i want to add the attachmnet which is tagged with the case.

Maybe you can add the following code between the <messaging:htmlEmailBody> tag:
<apex:repeat value="{!relatedTo.Attachments}" var="a">
<p><a href="{!URLFOR($Action.Attachment.Download, a)}">{!a.Name}</a> ({!a.BodyLength} B)</p>

You can also refer to the below links: