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
Timothy KeithTimothy Keith 

Visualforce Email: How do yu add the Opportunity Owner and Opportunity Team to Visualforce Email Template


I am creating my first visualforce email. 

I am trying to list the Opportuntiy; owner, contact roles, and  opportuntiy team all on email template. I been able to figure out how to add the opportunity contact roles but I can't figure out how to add the Opportuntiy Owner and Opportuntiy team through the email code. 

Please see my visualforce code below. Thanks in Advance! 

<messaging:emailTemplate subject="Testing VF" recipientType="User" relatedToType="Opportunity">
<messaging:plainTextEmailBody >
This is testing the text section....
Opportunity Name: {!}
Account: {!}
Amount: {!Relatedto.amount}
Contact Roles for this Opportunity:
<apex:repeat value="{!RelatedTo.OpportunityContactRoles}" var="ContactRole">
{!ContactRole.Contact.Name} {!ContactRole.Contact.Email}
<apex:repeat var="team" value="{!relatedTo.opportunityteammembers}">


NagendraNagendra (Salesforce Developers) 
Hi Timothy,

Opportunity Owner to Email Template:When using the Owner field in an Email Template you have a few options of what to display in the email. If you would like to show the full name of the owner. You would need to use 
Using just the first name would be using this
This can be done with Last Name, ID, email and title as well.

Opportunity Team Members to email template:To list the team members in the email body will require a Visual Force email template so you can reference the related team records. You can add the team to the recipients of the Email Alert though so the Boss can see who else is on the email notification (and as a side effect, when the Boss replies "great job", the team members will get the reply all)

Please mark this as solved if it helps.

Best Regards,

Timothy KeithTimothy Keith
Hello Nagendra,

Thanks for the quick response. 

To you your point. How can I list the opportunity team members in the email body with the Visual Force email template. How can I refrence the related team records? 

A sample script would be very helpful. 

Thanks again for all the help.