1

I want to send out emails to the system admin when there is a Fatal exception thrown in our managed package. I'm aware that a managed package has an option of 'send email on apex error' but that sends out an email in case of uncaught exceptions.

My current implementation is to create Messaging.SingleEmailMessage when an exception is hit and send it out. However, it can reach governor limits quickly in case of a lot of Errors.

Is there a way to queue up the emails to a sender address and send it at a scheduled time using apex code?

Is there a best practice in terms of how to handle known exceptions and inform the system admin?

0

One option is to implement a custom log object. You could then insert a record in the event of a handled exception (you may need to use a @future method to perform the DML in some cases like constructors). The subscriber then has a list of errors they can access via the standard UI and can also create workflow email alerts if they want more immediate notification.

  • Thanks for your response. That seems like a viable approach. However, was also hoping to find a solution to the email governor limit issue as it seems like a fairly common problem for managed packages sending out emails. – Tan May 4 '17 at 19:07

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.