You need to sign in to do that
Don't have an account?
Visualforce Email Templates,Require help.
Hai to Salesforce,
I want to send an email alert to user when the task is overdue, unfortunately we don't have option to send overdue email through workflows, so the only option is Apex code and Visualforce email template,but i have searched enire to get about Vfemail templates, but i didn't get needed information forme,
please help me , I am creating Vfemail template sucessfully,and in verify test and getting merge fields also,
Now i am having doubt like, how we can send that Email template to User through Trigger and how i can pass record ID to that template in trigger. please help me
Regards,
Haribabu
Try using this:
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
mail.setTemplateId(EmailTemp.Id);
mail.setSaveAsActivity(true);
mail.setReplyTo('123@213.com);
mail.setSenderDisplayName('Sender');
mail.setWhatId('AssociateId');
mail.setTargetObjectId('Contact OR Lead ID');
Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
All Answers
Try using this:
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
mail.setTemplateId(EmailTemp.Id);
mail.setSaveAsActivity(true);
mail.setReplyTo('123@213.com);
mail.setSenderDisplayName('Sender');
mail.setWhatId('AssociateId');
mail.setTargetObjectId('Contact OR Lead ID');
Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
Hai Osaman,
I too Know this, WHat i am asking is, i have used merge fields in that template,how we can pass the current record ID to that Email template, so that i can get data in to my template.
Regards,
Haribabu
You need to set the Target Object Id field to set the current record.
Thank you for Quick response,
From where i can send that ID, how i can ?If you have any sample please send it to me.
Regards,
Haribabu.
Thats what I included in my first post
mail.setTargetObjectId('Contact OR Lead ID'); // You need to set this Id with a contact or lead object. Since the user is actually the owner of one of these records, the merge field will pick up the vlaue.
mail.setWhatId('Account, Opportunity or any related object Id'); //if you have placed merge fields with opportunity/quote or any other related object owner.
Hai ,
I need to Pass Task iD , how i can.I am populating taskfields,how i can.
Regards,
Haribabu.
Set the task Id here mail.setWhatId()