4

In a partial sandbox I am calling Messaging.sendEmail through an @InvocableMethod through a Flow, and emails are not going out for a non-admin profile. There are no errors anywhere and even debugging Messaging.SendEmailResult.isSuccess() shows true. The arrangement works fine for an admin user.

I haven't tried with other profiles (or in other sandboxes or in Production) but I have verified that every occurrence of the word "email" throughout this one profile is met with a ticked box. Email deliverability is set to All Emails (should be obvious by now, but just being explicit) and the code is setting templateId, whatId, and targetObjectId. Dead basic. The profile in question has access to the template and the related records in whatId and targetObjectId.

FWIW I have also tried with toAddresses in the email with no luck.

3
  • 1
    Does the user have a valid email address on their user record in the sandbox (ex, not .invalid)? May 5, 2021 at 23:51
  • and you checked the email logs to see if the email was sent/delivered?
    – cropredy
    May 6, 2021 at 1:56
  • @KrisGoncalves That was it!! Turned out the user hadn't verified the email change yet. The user's email was .invalid. Happy to mark your reply as best answer.
    – Mossi
    May 6, 2021 at 8:09

1 Answer 1

3

There's a note at the bottom of this help document that clarifies there was a recent change (Summer '19) that is causing your issue

Please note as of Summer Release 19', Users must have a verified email address and .invalid removed from the email address in order to send email alerts via Workflow, Process, Flows or Triggers.

I didn't find any note about it in Summer '19, but did see that Spring '19 introduced the change to append .invalid to user email addresses in sandboxes which is most likely the source of the change.

Either way, if you change the user you're using/testing with to have a valid email address then the emails should send out.

Just remember the user has to verify the email change through an email message they receive from Salesforce before the email actually changes

1
  • I think I originally misinterpreted this answer, so I'm adding the clarification in case anyone else needs it. Change the email of the user YOUR ARE LOGGED IN AS, along with the recipient! That's because Salesforce will send the email from "[email protected] on behalf of USER_WHO_TRIGGERED_EMAIL". Therefore your email needs to be a valid one. Feb 13 at 16:39

You must log in to answer this question.

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