Skip to main content
Mo Yang (Rocket) ha preguntado en #Apex
I followed this link (http://www.jitendrazaa.com/blog/salesforce/send-visualforce-as-an-email-attachment-from-apex-trigger-alternate-design/) to send Visualforce page as an email pdf attachment using process builder. How do I get the individual record's information to show up on the PDF? In the Visualforce page, I have the vaules as outputText, but they are not showing up in the pdf attachment. Help appreciated!!! Thanks!!

Here is the Visualforce Page:

<apex:page standardController="BPA__c" renderAs="pdf">

<h1>Here's a copy of your BPA</h1>

<p>Thank you, <b><apex:outputText value=" {!BPA__c.BPA_Signer__r.Name}"/></b>, for

joining Our Network!</p>

<p>BPA Signed Date:&nbsp;

<apex:outputText value="{0,date,long}">

<apex:param value="{!BPA__c.BPA_Signed_Date__c}"/>

</apex:outputText></p>

</apex:page>

Here is the Apex Class:

public class sendAnEmail {

@InvocableMethod

public static void sendEmail(List<Id> lstId){

List<String> EmailIds = 'emailaddress@email.com'.split(',');

PageReference ref = page.bpa;

Blob b = ref.getContentAsPDF();

Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();

Messaging.EmailFileAttachment efa1 = new Messaging.EmailFileAttachment();

efa1.setFileName('attachment_BPA.pdf');

efa1.setBody(b);

String addresses;

email.setSubject( 'BPA PDF' + String.valueOf(DateTime.now()));

email.setToAddresses( EmailIds );

email.setPlainTextBody('Hey there, Thank you for Joining the Network!');

email.setFileAttachments(new Messaging.EmailFileAttachment[] {efa1});

Messaging.SendEmailResult [] r = Messaging.sendEmail(new Messaging.SingleEmailMessage[] {email});

}

}

2 respuestas
0/9000