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
biggabigga 

Opportunity Field in Plain Text Email Template

I have a button on opportunities to send an email to the primary contact role for that opportunity. I'm trying to add the Opportunity Description to that email.

This works:
<messaging:emailTemplate subject="Your recent order" recipientType="Contact" replyTo="myemail@mydomain.com" relatedToType="Opportunity">
<messaging:plainTextEmailBody >
Hi {!Recipient.Firstname} -

Last year around this time you ordered XXX from us at Our Company. Is it time to do that again?

Please let me know if I can help you with anything. Thanks!

</messaging:plainTextEmailBody>
</messaging:emailTemplate>

But I have to manually replace XXX with the opportunity description. Adding {!Opportunity.Description} to the template gives me this error:

Error: Unknown property 'core.email.template.EmailTemplateComponentController.Opportunity'

How can I include this Descriiption in an email? 
Best Answer chosen by bigga
Elie.RodrigueElie.Rodrigue
Thats the issue! The p3_lkid should be {!Opportunity.Id} instead of {!Account.Id} .

All Answers

Elie.RodrigueElie.Rodrigue
You should use {!relatedTo.Description} instead of {!Opportunity.Description}
biggabigga
Thanks tons for the reply. While {!relatedTo.Description} doesn't show an error, when it's used, nothing is returned in that space. 

Do I need to specify the Opportunity Description more clearly somehow? 
Elie.RodrigueElie.Rodrigue
Does the user sending the email have read access to that field?
biggabigga
In my org, I'm the only user, and I'm the admin. So I'm assuming that I have access to that field since I can edit it on the Opportunity page. 
Elie.RodrigueElie.Rodrigue
How does your button work? If you use the normal send email button from the opportunity and the select the template? does it work? I just tried it in my test org and its working fine using {!RelatedTo.Description}
biggabigga
I implemented this button when I first started in SF in 2011 - the button executes a javascript that loads the template, which populates the correct fields: To, From, Reply-To, Subject, and the message body all come from from the email template. 

Here's the JS of the button

location.replace('/email/author/emailauthor.jsp?p2_lkid={!Contact.Id}&rtype=003&p3_lkid={!Account.Id}&template_id=00XE0000000YHV1&retURL=/{!Opportunity.Id}&p5=myBCCemailaddyhere@domain.com')
Elie.RodrigueElie.Rodrigue
Thats the issue! The p3_lkid should be {!Opportunity.Id} instead of {!Account.Id} .
This was selected as the best answer
biggabigga
You're a genius Elie. Problem solved. Thanks for the help fixing this up today.
Elie.RodrigueElie.Rodrigue
No problem! Please don't forget to mark my solution as the best one!

Regards