You need to sign in to do that
Don't have an account?
Trigger to send email to Manager when the new project is created
Hi every body,
I want to write a Trigger to send email to Manager, when the new project is created. So, how can i write it?
I want to write a Trigger to send email to Manager, when the new project is created. So, how can i write it?
You can check this code.
Trigger :
trigger EmailSend on New_Leads__c (before insert) {
list<Messaging.SingleEmailMessage> mails=new list<Messaging.SingleEmailMessage>();
for(New_Leads__c newlead:trigger.new){
if (newlead.Email__c != null && newlead.Name!= null){
Messaging.SingleEmailMessage mail =new Messaging.SingleEmailMessage();
List<String> sendTo = new List<String>();
sendTo.add(newlead.Email__c);
mail.setToAddresses(sendTo);
mail.setReplyTo('thulasi.204@gmail.com');
mail.setSenderDisplayName('Official mail from Knightcapitalfunding');
List<String> ccTo = new List<String>();
ccTo.add('thulasi.204@gmail.com');
mail.setCcAddresses(ccTo);
mail.setSubject('URGENT BUSINESS PROPOSAL');
String body = 'Dear ' + newlead.Name+ ', ';
body += 'I confess this will come as a surprise to you.';
body += 'I am John Alliston CEO of the Bank of Nigeria.';
body += 'I write to request your cooperation in this ';
body += 'urgent matter as I need a foreign partner ';
body += 'in the assistance of transferring $47,110,000 ';
body += 'to a US bank account. Please respond with ';
body += 'your bank account # so I may deposit these funds.';
mail.setHtmlBody(body);
mails.add(mail);
}
}
Messaging.sendEmail(mails);
}
http://amitsalesforce.blogspot.in/2015/11/singleemailmessage-vs-massemailmessage.html
Sample code
Please let us know if this will help you
Thanks
AMit Chaudhary
Review all error messages below to correct your data.
Apex trigger SendEmailToManager caused an unexpected exception, contact your administrator: SendEmailToManager: execution of AfterInsert caused by: System.QueryException: List has no rows for assignment to SObject: Trigger.SendEmailToManager: line 10, column 1"