+ Start a Discussion

How to add a table to an email template

Hi guys,

Is it possible to add a table to an email template?
Ashish GargAshish Garg
You need to create a Visualforce Template type email template for this. In the same, then you can create Apex:Datatable or simple html table.
Remember: style classes does not work in email template, for this use inline style classes thoughout the html.

Ashish Garg
Amit Chaudhary 8Amit Chaudhary 8
Please check below post for Visualforce email template
1) https://developer.salesforce.com/page/VisualForceEmailTemplates_sample

I hope below will help you
<messaging:emailTemplate recipientType="Contact"
  subject="Case report for Account: {!relatedTo.name}"
        <STYLE type="text/css">
          TH {font-size: 11px; font-face: arial;background: #CCCCCC;
               border-width: 1;  text-align: center } 
          TD  {font-size: 11px; font-face: verdana } 
          TABLE {border: solid #CCCCCC; border-width: 1}
          TR {border: solid #CCCCCC; border-width: 1}
        <font face="arial" size="2">
          <p>Dear {!recipient.name},</p>
          <p>Below is a list of cases related to the account: {!relatedTo.name}.</p>
          <table border="0" >
            <tr > 
               <th>Case Number</th>
               <th>Creator Email</th>
            <apex:repeat var="cx" value="{!relatedTo.Cases}">
                <td><a href="https://na1.salesforce.com/{!cx.id}">View</a> |  
                <a href="https://na1.salesforce.com/{!cx.id}/e">Edit</a></td>
          <p />
  <messaging:plainTextEmailBody >
    Dear {!recipient.name},
    Below is a list of cases related to Account: {!relatedTo.name}
    [ Case Number ] - [ Subject ] - [ Email ] - [ Status ]
    <apex:repeat var="cx" value="{!relatedTo.Cases}">
      [ {!cx.CaseNumber} ] - [ {!cx.Subject} ] - [ {!cx.Contact.email} ] - [ {!cx.Status} ]
    For more information login to http://www.salesforce.com

Stancioiu Stefan 1Stancioiu Stefan 1
Hi guys, Anybody help me to write this batch? I'm new on salesforce. Thanks !

1.  Create a batch class that summarizes all Opportunity Amounts for each Account;
2.  An email should be sent to the primary contact of all Accounts, containing a table with the Closed Won/Open/Closed Lost summarized Opportunity Amounts;
3.  Schedulable class that calls the batch class should be created;
4.  The class should be scheduled from the Developer console. Please provide script to schedule the job daily at 10:00 AM, once a week (Friday at 1:00 PM), once a month(Last Friday of the Month at 6:00 PM).