Skip to content

Instantly share code, notes, and snippets.

@darshilv
Created April 8, 2013 20:37
Show Gist options
  • Save darshilv/5340270 to your computer and use it in GitHub Desktop.
Save darshilv/5340270 to your computer and use it in GitHub Desktop.
Sending email on exception generation when all debug methods are exhausted
try{
//statements that might generate exceptions
} catch (Exception e) {
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
String[] toAddresses = new String[] {''};
mail.setToAddresses(toAddresses);
mail.setReplyTo('support@acme.com');
mail.setSenderDisplayName('Salesforce Support');
mail.setSubject('Exception');
mail.setBccSender(false);
mail.setUseSignature(false);
mail.setPlainTextBody(e.getMessage());
Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
}
@ssinghvi
Copy link

ssinghvi commented Apr 8, 2013

Helpful. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment