Home Custom Email Template Visual Force Email Templates 2
Using custom components makes lots of stuff possible. Here’s an example of a year-end giving thank you email:
screenshot
This shows all gifts for 2008 and attaches a PDF of the giving history as well. Note that this is done just by connecting to the Contact, so this would work in the Salesforce.com mass mail interface.
Update: You cannot use vf templates in mass email or in the apex outboundemail method in Winter ’09. Maybe next release…
Also note that it’s an ugly HTML email just because I’m not a designer. You can make this as professional as you’re willing to make it.
Here’s the relevant code:

The VisualForce Email Template
    

Hello {!recipient.Household_Greeting__c}--

Thank you so much for you giving this year. Every gift helps us make a difference in our envrionment...



We look forward to seeing you in 2009!

Best, Steve

2008 Giving History for {!recipient.Household_Greeting__c}

The VisualForce Component that is included in the Email Template:
   
 
The Apex Controller that powers the logic for the VisualForce Component:



public class thisYearGivingTableController { //capture the contact id public Id thisContactId {get;set;} //a list to hold this year's gifts public List thisYearOpps = new List(); //get the gifts into the list public List getThisYearOpps() { //criteria for opps thisYearOpps = [SELECT Id, Amount,CloseDate, Check_Date__c, Check_Number__c FROM Opportunity WHERE IsWon=true AND Year__c=:String.valueOf(system.Today().Year()) AND Id IN (SELECT OpportunityId FROM OpportunityContactRole WHERE ContactId = :thisContactId AND Role='Individual Donor') ORDER BY CloseDate]; return thisYearOpps; } } 

You may also like

Leave a Comment

*