Created
April 8, 2013 20:37
-
-
Save darshilv/5340270 to your computer and use it in GitHub Desktop.
Sending email on exception generation when all debug methods are exhausted
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Helpful. Thanks!