You need to sign in to do that
Don't have an account?

Set a parameter in email template
Hi all,
I created a Email Template by Visualforce. Then I call a component. Code this:
<apex:component controller="BulkEmailSenderController" access="global">
<apex:dataTable value="{!selectedOpportunities}" var="s_account">
<apex:column>
<apex:facet name="header">Account Name</apex:facet>
{!s_account.oppObject.Account.Name}}
</apex:column>
</apex:dataTable>
</apex:component>
Then I create a send email button. I want set a value in {!selectedOpportunities}. How I can set value in parameter in Salesforce. My function send email:
Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
String[] toAddresses = new String[] {'vopp@systena.co.jp'};
// Set the paramaters of the email
email.setTargetObjectId('003N000000Lalmz');
email.setToAddresses( toAddresses );
email.setTemplateId('00XN0000000DzEJ');
// Send the email
Messaging.SendEmailResult [] r = Messaging.sendEmail(new Messaging.SingleEmailMessage[] {email});
I created a Email Template by Visualforce. Then I call a component. Code this:
<apex:component controller="BulkEmailSenderController" access="global">
<apex:dataTable value="{!selectedOpportunities}" var="s_account">
<apex:column>
<apex:facet name="header">Account Name</apex:facet>
{!s_account.oppObject.Account.Name}}
</apex:column>
</apex:dataTable>
</apex:component>
Then I create a send email button. I want set a value in {!selectedOpportunities}. How I can set value in parameter in Salesforce. My function send email:
Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
String[] toAddresses = new String[] {'vopp@systena.co.jp'};
// Set the paramaters of the email
email.setTargetObjectId('003N000000Lalmz');
email.setToAddresses( toAddresses );
email.setTemplateId('00XN0000000DzEJ');
// Send the email
Messaging.SendEmailResult [] r = Messaging.sendEmail(new Messaging.SingleEmailMessage[] {email});
You could create a Static property in another Class. Like this
Public class ConstantController{
public static String constantStringForTemplate{get;set;}
}
and set the property 'constantStringForTemplate' in your function for sendEmail button, whatever you wish.Use this property in your component.
I think it would work.
Thanks
Nitin
All Answers
Use component controller like below to set {!selectedOpportunities} value.
Let us know if it helps you.
I want my value will change by code, example: I want set String '123' in this email, but will set String 'abc' for other email. Please help me. Thank all
Can you please explain your requirement in more detail .
I created a variable selectedOpportunities contain check object. I want set value of this variable to my email template. How I can do it?
Please try below code . Please filter opportunity query as per your need.
Let us know if it helps you.
You could create a Static property in another Class. Like this
Public class ConstantController{
public static String constantStringForTemplate{get;set;}
}
and set the property 'constantStringForTemplate' in your function for sendEmail button, whatever you wish.Use this property in your component.
I think it would work.
Thanks
Nitin