+ Start a Discussion
Chad RitchieChad Ritchie 

Visualforce Email Questions

Hey guys,

So I'm new to creating Visualforce Email Templates. I'm really struggling to understand two things (and my code is below). First, where I mention Opportunity Requests below, what would the code look like to bring in a list from the opportunity object of all of their opportunities, but still have contact as the primary object. For example: Dear John Smith, here's a list of your opportunities: Opp1 Name, Opp2 Name, Opp3 Name.
So how would this work, since it's not as intuitive as merge fields, and second how would the code work so if someone has 20 Opps it looks good, and if someone has just 1 Opp it looks good, meaning not a ton of blank space. I know this is a lot to ask for, but I think if I can get down how to bring in cross-object info, similar to merge fields, and how to make info look good regardless of how many instances there are, than I'll be well on my way. THANKS so much!!!

<messaging:emailTemplate subject="Thanks for your Business" recipientType="Contact" relatedToType="Contact" >
<messaging:htmlEmailBody >
<style type="text/css">
body {font-family: arial; size: 12pt;}
Dear {!RelatedTo.Firstname},

Thank you for completing the following Opportunity Requests:

Raj VakatiRaj Vakati
You need to use visualforce based email tempate along with the controller