+ Start a Discussion

SendEmailError not being populated

I'm sending an email to a contact which I expect to fail (the contact has NO email address specified):




List<Messaging.SingleEmailMessage> emailList = new List<Messaging.SingleEmailMessage>();
Messaging.SingleEmailMessage sem = new Messaging.SingleEmailMessage();
sem.setSubject('test subject');


List<Messaging.SendEmailResult> sendEmailResult = Messaging.sendEmail(emailList, false);
System.Debug('@@@@ '+sendEmailResult);


 Here is the result that comes back:


13:08:57 INFO  - 20090325170853.851:AnonymousBlock: line 13, column 1: @@@@ (Messaging.SendEmailResult[getErrors=(Messaging.SendEmailError[getTargetObjectId=null;]);isSuccess=false;])


Why is the SendEmailError object not being fully populated?


I would expect the following to be populated:

- getMessage

- getStatusCode

- getTargetObjectId



Message Edited by dev_force on 03-25-2009 10:13 AM
Message Edited by dev_force on 03-25-2009 10:42 AM
Message Edited by dev_force on 03-25-2009 12:58 PM
Nobody encounters a similar issue running the code above?

I too have meen having trouble with using the SendEmailError setup. When I use your code I get TargetObjectID=null and IsSuccess= false - despite the fact that when I output the mail itself I see the "GetTargetObjectID" isn't null.



20090420143415.749:Class.Send_Single_Email_Class.SendEmail: line 113, column 9: EmailErrors: (Messaging.SendEmailResult[getErrors=(Messaging.SendEmailError[getTargetObjectId=null;]);isSuccess=false;]) 20090420143415.749:Class.Send_Single_Email_Class.SendEmail: line 115, column 9: THIS IS THE MAIL:Messaging.SingleEmailMessage[getBccAddresses=();getCcAddresses=();getCharset=null;getDocumentAttachments=null;getFileAttachments=null;getHtmlBody=null;getPlainTextBody=null;getTargetObjectId=00550000000rnCRAAY;getTemplateId=00XQ0000000HtVKMA0;getToAddresses=(brian.kwong@pharmacyonesource.com);getWhatId=500Q0000000fgfDIAQ;isUserMail=true;]


Rasmus MenckeRasmus Mencke
Thanks for posting this, we will look at the error codes and evaluate how we can improve it.
Anthony Magalit IIAnthony Magalit II

I'm also seeing this bug.  getTargetObjectId returns null.  Looks like this has been around for awhile.


Can we get a fix?