You need to sign in to do that
Don't have an account?
seshu.babu1.3923612903234636E12
email functionality
I want to send an email when the record is created.Example when the data comes from the informatica (ETL) to salesforce, another object record will be created and after the it will send the email.
The mails might be bulk emails or individual emails (morethan 400) with attachment.
Any body have any idea how to write code. Please help
The mails might be bulk emails or individual emails (morethan 400) with attachment.
Any body have any idea how to write code. Please help
trigger emailLeads on Lead (after update) {
List<Messaging.SingleEmailMessage> mails = new List<Messaging.SingleEmailMessage>();
List<Lead> allLeads = new List<Lead>();
for (Lead exLead : Trigger.new) {
Lead OldexLead = Trigger.oldMap.get(exLead.Rating);
Boolean OldexLeadnotRating = OldexLead.Rating.equals('Cold');
Boolean OldexLeadRating = exLead.Rating.equals('Cold');
if(!OldexLeadnotRating && OldexLeadRating) {
allLeads.add(exLead);
system.debug(allLeads);
}
for (Lead leadslist : allLeads) {
if (leadslist.email != null) {
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
List<String> sendTo = new List<String>();
sendTo.add (leadslist.Email);
mail.setToAddresses(sendTo);
mail.setReplyTo('jfaderanga@salesforce.com');
mail.setSenderDisplayName('The Pips Company');
mail.setSubject('Urgent Business Proposal');
String body = 'Dear ' + leadslist.FirstName +' ,' + '<br / ><br />' ;
body += 'I would like to say thanks to everybody that has been part of my lead';
body += 'I was so amaze about the story of life you all have shared to me';
body += 'I am hoping we meet again someday, cause its been a day since we first began the journey' + '<br /> <br />';
mail.setHtmlBody(body);
mails.add(mail);
}
Messaging.sendEmail(mails);
}
}