Can any one help me out . How to send an email to Account Owner from contract object in Batch Class.Im using templateid ,in target object im giving the contact id ,in whatid im sending the Account owner email ,but the Account owner is not getting any email.What im doing is correct .Any help very much appreciated.

Portion of Code :

global void execute(Database.BatchableContext bc, List < Contract >
     recs) {
            List < Messaging.SingleEmailMessage > mailList = new List < Messaging.SingleEmailMessage > ();
             for (Contract c: recs) {
                if (c.Contact_Email__c != null) {
                    List < String > toAddresses = new List < String > ();
                     List < String > CcAddresses = new List < String > ();
                    Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
                    // mail.setToAddresses(toAddresses);
  • ahh here you need to set targetobjectId will be Account ownerId – Ratan Paul May 6 '16 at 9:08
  • @Ratan:Thanks for your response.But the targetObjectId (a contact, lead, or user).Can i use Account id in targerObjectid.Any Suggestion please. – SalesforceCRM AccountCRM May 6 '16 at 11:00
  • Account ownerId means it is a user so you can use that Account's ownerid in targetObjectId – Ratan Paul May 6 '16 at 11:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.