2

I have a batch job that send emails on user anniversaries. It works when I run it in the execute anonymous window from SF's developer window. I'm sending it through the org-wide email address and I've given it "all profiles" under allowed profiles. When I try to run this same batch job through a scheduled apex job, it throws this error:

Apex script unhandled exception by user/organization: 005a0000009bsmS/00D540000008dr3 Source organization: 00D30000000VZXp (null) Failed to process batch for class 'RL_SendAnniversaryEmails' for job id '707540000076aHh'

caused by: System.EmailException: SendEmail failed. First exception on row 0; first error: INSUFFICIENT_ACCESS_OR_READONLY, Not profiled to access this Org-wide Email Address: []

I have already made sure the Org-wide Email Address in question is available to all Profiles. What else would prevent me from sending emails through a scheduled batch job?

  • 1
    how does the code determine the orgwide email address to use? are you in fact retrieving via SOQL a valid OrgWide email address? was it written using hard coded IDs that worked in sandbox but may not work in PROD? – cropredy Feb 5 '16 at 21:24
  • You might have reached the email limit. Please check. – DJD Feb 6 '16 at 4:55
  • double check again i think you have missed any newly created custom profile or some other person might change the permission. – Tushar Sharma Feb 6 '16 at 7:32
  • @crop1645 I didn't hard code the ID for the orgwide email and I'm currently testing it in sandbox and giving me the error. The SOQL I have actually looks up an email based on the name. This is why I'm so confused about the error. – slim Feb 7 '16 at 1:36
  • @Giene I don't think so. No emails really go out in my sandbox org. – slim Feb 7 '16 at 1:36

Your Answer

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

Browse other questions tagged or ask your own question.