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
Miller 95Miller 95 

Static Fields within Visualforce Email Template

Hi everyone,

I am trying to build out an email template that will not have me select which related to object because it will be predefined within the html code. I don't want to go in and update the fields by writing in the numbers. I need it to grab the field  based off the specific ID that is predefined within the html code.

This is where I am at:

<messaging:emailTemplate recipientType="Contact"
relatedToType="PricebookEntry"

subject="Stock Listings"

replyTo="me@me.com">
<messaging:htmlEmailBody >
<html>
<body>
<style>
<table>

.xl90
    {mso-style-parent:style16;
    color:windowtext;
    font-size:9.0pt;
    font-family:Arial, sans-serif;
    mso-font-charset:0;
    text-align:center;
    vertical-align:middle;
    border-top:none;
    border-right:1.5pt solid black;
    border-bottom:1.5pt solid black;
    border-left:1.5pt solid black;
    white-space:normal;}
.xl91
    {mso-style-parent:style16;
    color:windowtext;
    font-size:9.0pt;
    font-family:Arial, sans-serif;
    mso-font-charset:0;
    mso-number-format:"\#\,\#\#0_\)\;\\\(\#\,\#\#0\\\)";
    text-align:center;
    vertical-align:middle;
    border-top:none;
    border-right:1.5pt solid black;
    border-bottom:1.5pt solid black;
    border-left:1.5pt solid black;
    white-space:normal;}

</table>
</style>
<tbody>

<tr class="xl65535" style="mso-height-source:userset;height:19.0pt" height="19">
<td colspan="2" class="xl96" style="border-right:1.5pt solid black;height:19.0pt;width:146pt" height="19" width="146">Hard Maple First Grade</td>
        <td class="xl90" style="border-left:none;width:65pt" width="65">3-14'</td>
        <td class="xl91" style="border-left:none;width:51pt" width="51">{!relatedto.000000000m00HaX12T.unitPrice}</td>
        <td class="xl91" style="border-left:none;width:51pt" width="51">{!relatedto.000000000m00AD32gT.unitPrice}</td>
<br />
</td>
</tr>
</tbody>
</table>
</html>
</messaging:htmlEmailBody>
<messaging:plainTextEmailBody >
    
</messaging:plainTextEmailBody>  
</messaging:emailTemplate>

Is this even possible to have mulitple IDs being used within the code and how would I grad specific fields so become a static output?
Adeel Ahmad 17Adeel Ahmad 17
you should create the visualforce component with parentId as parameter and include that in your visualforce email template.