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
Pavani Akella 9Pavani Akella 9 

table related list on email template

I have written a visualforce page but I'm stuck how to keep the table spacing(lines) and also how to add few other fields:

I would like to add the below fields:
Please order replacements parts for the following case.
Case Number: 
Case Subject: TEST CASE
Claim Type: Warranty

The link to the case is below. https://cs1.salesforce.com/500S0000008x9mL

And also I would like to see a line spacing between each row
Part NameDescription
a1XS0000001eJ05MAEDNO - B28 - BRACKET- SRM - REWORKED
a1XS0000001eJ0FMAUWASHER - 19/32in ID X 1-11/64in OD - 11/64in THICKNESS - AL
a1XS0000001eJ07MAECLAMP - 1/2in EPDM CUSH GALVANIZED MED DUTY - HOLE DIAMETER


<messaging:emailTemplate recipientType="Contact"
    relatedToType="Case"
    subject="Test: "
    replyTo="support@acme.com" >
    
<messaging:htmlEmailBody >
<html>
    <body>
    <STYLE type="text/css">
        TH {font-size: 12px; font-face: arial;background: #CCCCCC; border-width: 1;  text-align: center } 
        TD  {font-size: 12px; font-face: verdana } 
        TABLE {border: solid #CCCCCC; border-width: 1}
        TR {border: solid #CCCCCC; border-width: 1}
     </STYLE>
     <font face="arial" size="4">
Dear {!recipient.name},
 
<p>Please order replacements parts for the following case</p>

[ CaseNumber ] - [ Subject] - [ Claim_Type_new]
<table border="0" >
  <tr > 
        <th>Part Name</th><th>Description</th>
    </tr>  
    <apex:repeat var="cx" value="{!relatedTo.Replacement_Parts__r}">
        <tr>
           <td>{!cx.Replacement_Item__c}</td>
            <td>{!cx.Description__c}</td>
        </tr>
    </apex:repeat>                 
</table>
<p />
            </font>
        </body>
    </html>
</messaging:htmlEmailBody> 

</messaging:emailTemplate>

Can someone help me how to do? Thanks in advance
Sukanya BanekarSukanya Banekar
Hi,
Below are the changes you should make to your html code also change the field api names accordingly
 
<tr style="padding: .5em;"> 
        <th>Part Name</th><th>Description</th><th>Case Number</th><th>Case Subject</th><th>Claim Type</th>
    </tr>  
    <apex:repeat var="cx" value="{!relatedTo.Replacement_Parts__r}">
        <tr>
           <td>{!cx.Replacement_Item__c}</td>
           <td>{!cx.Description__c}</td>
		   
		   <td>{!cx.Number}</td>   <!--Put case number field API name-->
		   <td>{!cx.Subject}</td>  <!--Put case suject field API name-->
		   <td>{!cx.ClaimTYpe}</td>  <!--Put ClaimType field API name-->
		   
        </tr>
    </apex:repeat>

Let me know if this helps.

Thanks,
Sukanya Banekar
Mustafa JhabuawalaMustafa Jhabuawala
Pavani,

You need to do following changes in your code - 

1. Add the required rows in the header and in the repeat part
2. Add cellspacing to the table to apply spacing
<table cellspacing="10">
   <tr> 
       <th>Part Name</th>
       <th>Description</th>
       <th>Case Number</th>
       <th>Case Subject</th>
       <th>Claim Type</th>
    </tr>  
    <apex:repeat var="cx" value="{!relatedTo.Replacement_Parts__r}">
        <tr class="rowSpacing">
           <td>{!cx.Replacement_Item__c}</td>
            <td>{!cx.Description__c}</td>
            <td>{!cx.CASENUMBER}</td>
            <td>{!cx.CASESUBJECT}</td>
            <td>{!cx.CLAIMTYPE}</td>
        </tr>
    </apex:repeat>                 
</table>

If cellspacing doesn't work for you then try using a height property by adding CSS class to tr
 
.rowHeight{
  height: 10px;
}