2

Recently I'm encountering some weird issues in Apex SendEmail() calls :-)

Messaging.sendEmail(LIST<Messaging.Email>)

can any one confirm if 1 item in the list of Emails to be sent errored out with an error like bounced for a contact, will All other emails as well errored out? Or it will still send out emails to rest of the list and report error for that item only?

2 Answers 2

3

As per official docs:

http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_classes_email_outbound_messaging.htm#apex_System_Messaging_sendEmail

Reading the text below, looks like the other messages have to be delivered to other contacts if there is a failure since default is false.

The sendEmailMessage method assumes that the optional opt_allOrNone parameter is always false and ignores the value you set. This optional parameter specifies whether sendEmailMessage prevents delivery of all other messages when any of the messages fail due to an error (true), or whether it allows delivery of the messages that don't have errors (false).

2
  • Yes that is it, thanks for the info and link, feeling really stupid to not to check docs first, before posting here.
    – VarunC
    Apr 8, 2014 at 19:08
  • No problem, we all have the need help moments :)
    – Rao
    Apr 8, 2014 at 20:23
3

Looks like the official documentation for this method has been updated since the last accepted answer:

public Messaging.SendEmailResult[] sendEmail(Messaging.Email[] emails, Boolean opt_allOrNone)

The optional opt_allOrNone parameter specifies whether sendEmail prevents delivery of all other messages when any of the messages fail due to an error (true), or whether it allows delivery of the messages that don't have errors (false). The default is true.

So now you have to explicitly set the second parameter to false if you want the code to deliver some of the emails when others have bounced.

Link to documentation.

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .