+ Start a Discussion
Bulent703Bulent703 

Email Template modification

Hi,

 

I have a requirement where I need to append text at the end of an email message. However, the email message is based on the template. If I try to get the email template body and send it as part of the email, the merge fields are not processed. Is there a good way to do this? 

sf11sf11
Try creating a VisualForce email template and have the email content modified based on conditions where you need to append the text.
magdielhfmagdielhf

I agree with the previous comment, this is how it works for me

 

(1)You might want to create a component,

 

(2)Assign a controller class to this component where you can process the logic you want,

 

(3)Include this component in your email template,

 

For example:

 

Inside the EmailTemplate

================

 

  <h1 class="title">
WE HAVE A WINNER !
******************************************
<c:ContestWinnerNotificationManagement >
</c:ContestWinnerNotificationManagement>
******************************************
</h1>

 

Component

=======

<apex:component controller="winnerManagement" access="global">
<apex:dataTable value="{!WinnerContestant}" var="s_contestant">
<apex:column >
{!s_contestant.contestant_full_name__c}
</apex:column>
</apex:dataTable>
</apex:component>

 

 Controller class

==========

public class winnerManagement {

    //private String uname;
    public String uname {get; set;}
    public String State {get; set;}
    
    private final contestant__c winnerInfo;

    public winnerManagement() {
        uname = UserInfo.getName();
    }
    
    public contestant__c getWinnerContestant(){
        return [Select contestant__c.contestant_full_name__c From contestant__c Where status__r.Name = 'Winner'];
    }
    
    public Pagereference sayHello(){
        uname = UserInfo.getName();
        return null;
    }  

    public contestant__c getWinner() {
        return winnerInfo;
    }
    
    public PageReference methodOne() {
        return null;
    }
    
    
    public CurrentMailBox__c getCurrentMailbox() {
        return [Select CurrentMailBox__c.Name, CurrentMailBox__c.currentAddress__c  From CurrentMailBox__c ];
    }
}