Require ment:
/* whenever task is completed we need send
confirmation mail to related account....
*/
Trigger Send_Email on Task (after insert,after update) {
list<account> acc;
for(Task tsk : Trigger.New)
{
if(tsk.status == 'completed'){
acc = [select name,email__C from account where id =: tsk.whatid];
}
}
for(account a :acc){
if(a.email__c != null){
string mal = a.email__C;
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
String[] toAddresses = new String[] {mal};
mail.setToAddresses(toAddresses);
mail.setSubject('A task owned by you has been updated');
String body = 'Dear ' + a.name + ', ';
body += 'I am informing about your task .';
body += 'I am varaprasad CEO of salesforce.';
body += 'your task is completed succesfully.. ';
mail.setHtmlBody(body);
Messaging.SendEmail(new Messaging.SingleEmailMessage[] {mail});
}
}
}
/* whenever task is completed we need send
confirmation mail to related account....
*/
Trigger Send_Email on Task (after insert,after update) {
list<account> acc;
for(Task tsk : Trigger.New)
{
if(tsk.status == 'completed'){
acc = [select name,email__C from account where id =: tsk.whatid];
}
}
for(account a :acc){
if(a.email__c != null){
string mal = a.email__C;
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
String[] toAddresses = new String[] {mal};
mail.setToAddresses(toAddresses);
mail.setSubject('A task owned by you has been updated');
String body = 'Dear ' + a.name + ', ';
body += 'I am informing about your task .';
body += 'I am varaprasad CEO of salesforce.';
body += 'your task is completed succesfully.. ';
mail.setHtmlBody(body);
Messaging.SendEmail(new Messaging.SingleEmailMessage[] {mail});
}
}
}