+ Start a Discussion

VisualForce Email Template Error

I'm trying to use VisualForce for the first time and since I have some HTML knowledge thought the email template might be the easiest place for me to start - I've got it complete but unfortunately keep getting errors upon save, here is what I have so far:


<messaging:emailTemplate recipientType="User"
subject="New Bookings{!relatedTo.Account.Name}"
<messaging:htmlEmailBody >
<b>Customer Name:</b> {!relatedTo.Account.Name} <br/>
<b>Date of Booking:</b> {!Opportunity.CloseDate} <br/>
<b>Total Committed Booking Amount:</b> {!Opportunity.Amount} <br/>
<b>Total At Risk Booking Amount:</b>{!OpptyLineItem__c.At_Risk_Bookings_Amount__c} <br/>
<b>Grand Total Booking:</b> {!Opportunity.Amount} <br/> <br/>

<table width="100%"
     style="border-style: solid; border-width: 1px; border-color: #00000">
<th>Volume (K)</th>
<th>CPM/CPL/Cost Per Month</th>
<td>{!relatedTo.OpptyLineItem__c.StartDate__c} - {!relatedTo.OpptyLineItem__c.EndDate__c} </td>

<b>Total:</b> {!Opportunity.Amount} <br/>
<b>Salesforce IO Number:</b> {!Opportunity.IONumber__c} <br/>
<b>Link to IO:</b> {!Opportunity.IO_Customer_URL__c} <br/>



I keep getting an error listed as: Unknown property 'core.email.template.EmailTemplateComponentController.Opportunity'


I suspect this is because I'm trying to call the related Account data and Opportunity Line Item data into the template but don't understand why it won't let me do that since both have direct relationships with the Opportunity object.




Ran across your post as I'm searching for something else, assume you figured it out by now, but if not, it looks like you set it up for User and then Opportunity, which of course don't relate, so that's probably what's going on.  Change User to Contact and I believe then you can either choose the related to as Opportunity, but if not, choose Account and you can traverse down to Opps fairly easily from there.