function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ 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 >
        <html>
        <img src="http://www.XXXX.com/ucmprdpub/groups/public/documents/logo/logo_png.png"/>
            <body>
            <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>
            <P>
                <apex:outputLink value="https://cs13.salesforce.com/{!relatedTo.id}">
                    Approve / Reject
                </apex:outputLink>
                <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.
                <Br/><Br/>
                <B> To Reject :</B> Please click on the above link.
                <Br/><Br/>
                <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.
            </P>
            <br/> <br/>
           <b> Previous approval history </b>

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



Regards
Shaker
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.
        </apex:repeat> 
        After the repeat component
    </messaging:attachment>
</messaging:emailTemplate>

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.