I have Query Regarding Simple Text Email Template.Here I have VF Page And Controller Class in that VF page I want to load Predefined Text Email Template....
Here is the VF Page Code....
<apex:page controller="EmailTemplateTestController">
<apex:form >
<apex:actionFunction name="send" action="{!send}" rerender="bodyField">
<apex:param name="c" value="" assignTo="{!emailBodyText}"/>
</apex:actionFunction>
<apex:pageBlock title="Compose Email" id="MainPage">
<apex:pageBlockSection columns="1">
<apex:pageBlockSectionItem >
<apex:outputLabel >To</apex:outputLabel>
<apex:inputText title="sending address" value="{!ToList}" id="ToField" styleClass="ToField" style="height:16px; width:200px;"/>
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem >
<span>Body</span>
<apex:inputTextarea value="{!templateBody}" style="width:400px ; height:400px"/>
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem >
<apex:commandButton value="Send" action="{!send}"/>
</apex:pageBlockSectionItem>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
And Controller Class Regarding VF Page....
public class EmailTemplateTestController{
public string ToField{get;set;}
public string ToList{get;set;}
public string ccList{get;set;}
public string emailBodyText{get;set;}
public string emailSubject{get;set;}
public EmailTemplate Templates{get;set;}
public String templateBody {get;set;}
public string Community_Name{get;set;}
public EmailTemplateTestController()
{
emailBodyText = '';
Community_Name = 'customer';
Templates = [Select Id, Name, IsActive,body,Folder.Name From EmailTemplate Where Name = 'VFEmailTemp' LIMIT 1];
templateBody = Templates.body ;
}
public PageReference send()
{
List<Messaging.SingleEmailMessage> lstMsgs = new List<Messaging.SingleEmailMessage>();
List<string> ToAddresses = ToList.split(',');
system.debug('-----ToAddresses --'+ToAddresses );
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
mail.setToAddresses(ToAddresses);
mail.setTargetObjectId('00590000001IIC3'); // User ID
mail.setTemplateId(Templates.Id);
mail.setHtmlBody(templateBody );
mail.saveAsActivity = false;
//mail.setHtmlBody(templateBody);
lstMsgs.add(mail);
// system.debug('-----lstMsgs--'+lstMsgs);
try{
Messaging.sendEmail(lstMsgs);
}
catch(Exception e)
{
system.debug('exception--'+e);
}
return null;
}
}
Here I want to Display In Template...
Hi Amezon113(user FirstName)
For that here i made template and id was used in the controller,here is the snapshot...
But in the output of VF page it displayed same as Binding in Template.......look output
Here I want to Display User's FirstName so what can i do for that,Please Any one Help Me to solve this query regarding Email Template....