function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
vin2sfvin2sf 

Send Mass Email through Apex getting getTargetObjectId=null

Hi,

 

Could anyone help me to find why i am getting getTargetObjectId=null though getTargetObjectId has value?

 

Please find the code to send mass email

 

messages.setTargetObjectIds(contactIds);

System.debug('contactids:'+contactIds);

System.debug('getTargetObjectIds:'+messages.getTargetObjectIds());

List<Messaging.SendEmailResult> resultList = Messaging.sendEmail(new Messaging.Massemailmessage[] { messages } , false);

 

 

Please find the debug log:

 

20091206092244.695:Class.SurveyCandidate.sendEmail: line 162, column 9: contactids:(003A0000003IfQ0IAK, 003A0000003IfQ1IAK)
20091206092244.695:Class.SurveyCandidate.sendEmail: line 164, column 9: getTargetObjectIds:(003A0000003IfQ0IAK, 003A0000003IfQ1IAK)
20091206092244.695:Class.SurveyCandidate.sendEmail: line 168, column 9: result:(Messaging.SendEmailResult[getErrors=(Messaging.SendEmailError[getTargetObjectId=null;]);isSuccess=false;])

 

 

Regards,

vin2sf

 

Message Edited by vin2sf on 12-06-2009 09:31 AM
Best Answer chosen by Admin (Salesforce Developers) 
pon-de-lionpon-de-lion
Hi, just so if anybody else might have run into the same issue, I believe it's not saying the ID is null, it's saying the e-mail address attached to that ID has problem (not valid or null...etc.), take out sendemail's second argument, or set it to true should have different error messages. hope this helps.
getTargetObjectId=null