1

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 at 23:51
  • and you checked the email logs to see if the email was sent/delivered?
    – cropredy
    May 6 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 at 8:09
1

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.