Timeline for "ExecutionException: List index out of bounds: 0" while sending email from Apex using email template with Custom Object merged fields
Current License: CC BY-SA 4.0
5 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Sep 14, 2022 at 14:39 | comment | added | Prapti | Hey @sfdcfox, there was an uncommented line System.debug('The email failed to send: ' + r.errors[0].message); in the success if statement, which was causing the issue. Now although I'm not getting the exception, the email is still not getting sent. I checked the Deliverability setting too, the access level is All email. Should I check any other settings that might be causing this? | |
Sep 14, 2022 at 14:19 | comment | added | sfdcfox♦ | There's no method for sending an email through LWC, you do need Apex. Perhaps you're sending in bad data? Do you know which line of code is throwing the error? | |
Sep 14, 2022 at 13:52 | comment | added | Prapti | @sfdcfox thanks, this method is called from the lightning component. Is there any way I can send just the one email I need to send? | |
Sep 14, 2022 at 13:08 | comment | added | sfdcfox♦ |
The problem doesn't appear to be here, especially if the final debug statement is being put out. However, note that you are sending two emails, not just one (setTargetObjectId is the recipient by default). Whatever index out of bounds error you're getting is in the code calling this code.
|
|
Sep 14, 2022 at 13:02 | history | asked | Prapti | CC BY-SA 4.0 |