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
Mr.Mittal_2617Mr.Mittal_2617 

HELP!! Visualforce Email Template HELP!!

Hi All,

I am trying to write an email template available for use using two object PRoduct and Purchase Orderline item. where product is master of purchase order lin item and email template hsould look like this 
User-added image
Please Help !!!
#Apex #Visualforce
#EmailTemplate

PriyaPriya (Salesforce Developers) 
Hi Mr. Mittal,

You need to create the visualforce Email Template and try the below sample code and modify it as per your requirement :- 
<messaging:emailTemplate recipientType="Contact"
  relatedToType="Account"
  subject="Case report for Account: {!relatedTo.name}"
  replyTo="support@acme.com">
  <messaging:htmlEmailBody>
    <html>
      <body>
        <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}
        </STYLE>
        <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>Action</th>
               <th>Case Number</th>
               <th>Subject</th>
               <th>Creator Email</th>
               <th>Status</th>
            </tr>
            <apex:repeat var="cx" value="{!relatedTo.Cases}">
              <tr>
                <td><a href="https://na1.salesforce.com/{!cx.id}">View</a> |  
                <a href="https://na1.salesforce.com/{!cx.id}/e">Edit</a></td>
                <td>{!cx.CaseNumber}</td>
                <td>{!cx.Subject}</td>
                <td>{!cx.Contact.email}</td>
                <td>{!cx.Status}</td>
              </tr>
            </apex:repeat>                 
          </table>
          <p />
        </font>
      </body>
    </html>
  </messaging:htmlEmailBody> 
  <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} ]
    </apex:repeat>
    
    For more information login to http://www.salesforce.com
  </messaging:plainTextEmailBody>    
</messaging:emailTemplate>


I hope below will help you.

Kindly mark it as the best answer if it helps.

Regards,

Priya Ranjan

Mr.Mittal_2617Mr.Mittal_2617
@Priya I have already done that but its not working