+ Start a Discussion
Shaker Kuncham 1Shaker Kuncham 1 

PDF Attachement getting blank through VF email Template

Hi All

I have creaed a approval process and uploading a PDF document and technical writer will submit for approval process, then approver will receive the email with PDF, however approver receiving the PDF but without content ( blank PDF ). Below is the code, 
<messaging:emailTemplate subject="Document Submitted" recipientType="User" relatedToType="Compliance_Documents__c">
<apex:image url="/servlet/servlet.FileDownload?file=015W0000000Dmru"
height="64" width="64"/>
    <messaging:htmlEmailBody >
        <img src="http://www.XXXX.com/ucmprdpub/groups/public/documents/logo/logo_png.png"/>
            <p>Dear {!recipient.name},</p>
            <p>Attached is document related to Compliance Document "{!relatedTo.Compliance_Document_Name__c} ". </p>
            <p>Please Review the document and <B> Approve/Reject.</B> To approve or reject this item, click this link </p>
                <apex:outputLink value="https://cs13.salesforce.com/{!relatedTo.id}">
                    Approve / Reject
                <Br/><Br/>or <Br/><Br/>
                <B> To Approve through email :</B> reply to this email with one of these words in the first line of the email message: APPROVE, APPROVED.
                <B> To Reject :</B> Please click on the above link.
                <B>For Comments: </B>
If replying via email, you can also add comments on the second line. Comments will be stored with the approval request in Salesforce CRM.
            <br/> <br/>
           <b> Previous approval history </b>

        <c:ApprovalItem recordId="{!relatedTo.Id}" />
            Kind Regards, <br/>
            Document Compliance Team
    <messaging:attachment filename="{!relatedTo.name}" renderAs="PDF">
        <apex:repeat var="cx" value="{!relatedTo.id}">

MJ Kahn / OpFocusMJ Kahn / OpFocus
You're not getting anything in your attachment becaue you're not putting anything in your attachment. You have a repeat component that doesn't have anything inside it. Try changing it to the following, and you'll see what I mean:

<messaging:attachment filename="{!relatedTo.name}" renderAs="PDF">
        Before the repeat component
        <apex:repeat var="cx" value="{!relatedTo.id}">
            This is a test.
        After the repeat component

If you want the body to contain something about the relatedTo object, you don't need a repeat component - repeat components are good for iterating over a list, but relatedTo.Id isn't going to be a list. Whatever it is you want to put into the body, put it in, in place of the repeat component.