Support Center

Creating an Email PDF Template

Last Updated: Apr 04, 2018 04:04PM PDT

Overview

Creating an Email PDF Template is for Quotes, Orders, and Invoices.  This article explains how to make an email template that contains a PDF in it.  

Audience : Administrator | Requires: Apex and Visualforce Knowledge


Steps:


Create New Visualforce Email Template:
1. Log into your Salesforce Instance | Go to Setup
2. Under Administration Setup | Click Communication Templates
3. Click Email Templates
4. Choose the folder for your new email template in (Ex. "Kugamon Email Template")
5. Click New Template | Select Visualforce | Click Next
6. Fill in the required fields:
  • Available for Use
  • Email Template Name and Template Unique Name
  • Email Subject
  • Recipient Type (Ex. Contact)
  • Related To Type (Ex. "kugo2p_SalesOrder_c" for Order, "kugo2p__SalesQuote__c" for Quote, and "kugo2p__KugamonInvoice__c" for Invoice)
  • Click Save
7. Set Available for Use checkbox to Active

Add Template Content:

1. Click Edit Template button
2. Enter your Email Template code
with the relevant sample code give below
3. Update the Subject and Body sections with appropriate language and field references. Make sure the Record Name in included in the Subject. This is how Kugamon knows if the Email has been Sent and thus able to update the Record Status.
 

Notes:

  • If you see the following error message, it is okay to ignore it:
Error occurred trying to load the template for preview: common.apex.runtime.impl.ExecutionException: Attempt to de-reference a null object. Please try editing your markup to correct the problem"

 

Sample Order Email Template:

Replace "Order" text to "Quote" to draft a Quote Email Template
<messaging:emailTemplate subject="{!$Organization.Name} Order: {!relatedTo.Name}"
recipientType="Contact" relatedToType="kugo2p__SalesOrder__c">

<messaging:plainTextEmailBody >
Dear {!relatedTo.kugo2p__ContactBuying__r.Name},                
        
Thank you for your interest in our offering. Please review and sign the attached order.
        
Feel free to contact me if you have any questions.

Regards,
        
{!$User.FirstName} {!$User.LastName}
{!$Organization.Name}
{!$User.City} | O: {!$User.Phone} | Email: {!$User.Email}
</messaging:plainTextEmailBody>
    
<messaging:attachment renderAs="pdf" filename="{!relatedTo.Name}">    
<kugo2p:OrderPDF orderId="{!relatedTo.Id}" />                           
</messaging:attachment>
    
</messaging:emailTemplate>


Notes:
  • Feel free to edit the Email Subject and Body
  • Do not alter code below </messaging:plainTextEmailBody>, for this code is the PDF assignment logic



Sample Invoice Email Template:


<messaging:emailTemplate subject="{!$Organization.Name} Invoice: {!relatedTo.Name}"
recipientType="Contact" relatedToType="kugo2p__KugamonInvoice__c">


<messaging:plainTextEmailBody >
Dear {!relatedTo.kugo2p__ContactBilling__r.Name},                


Thank you for your order approval. Please process the attached invoice.
        
Invoice Summary
- Invoice Number: {!relatedTo.Name}
- Invoice Due Date:&nbsp;<apex:outputText value="{0,date,MM/dd/yyyy}"><apex:param value="{!relatedTo.kugo2p__InvoiceDueDate__c}" /></apex:outputText>
- Invoice Amount:&nbsp;<apex:outputText value="{0,number,$###,##0.00}"><apex:param value="{!relatedTo.kugo2p__BalanceDueAmount__c}" /></apex:outputText>
        
Feel free to contact me if you have any questions.

Regards,
{!$User.FirstName} {!$User.LastName}
{!$Organization.Name}
{!$User.City} | O: {!$User.Phone} | Email: {!$User.Email}
</messaging:plainTextEmailBody>
    
<messaging:attachment renderAs="pdf" filename="{!relatedTo.Name}">    
        <kugo2p:InvoicePDF invoiceId="{!relatedTo.Id}" />                           
</messaging:attachment>
    
</messaging:emailTemplate>


Notes:
  • Feel free to edit the Email Subject and Body
  • Do not alter code below </messaging:plainTextEmailBody>, for this code is the PDF assignment logic



 

Contact Us

http://assets2.desk.com/
false
kugamon
Loading
seconds ago
a minute ago
minutes ago
an hour ago
hours ago
a day ago
days ago
about
false
Invalid characters found
/customer/en/portal/articles/autocomplete