• jrojas
  • NEWBIE
  • 0 Points
  • Member since 2013

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 1
    Replies

I am running a batch apex class that is scheduled to run periodically throughout the week. (It implements the schedulable interface.) As part of the finish method, I am attempting to create and send an email alerting users that the batch class has completed running. The code compiles / saves fine in the Sandbox - and my unit tests run fine in the Sandbox as well. However, we I go to deploy I get the following error that disappears if I comment out the email code:

System.Exception: Error processing messages

Here is the code within the finish method. Any help / thoughts are appreciated.

Thanks
-- Matt

 

global void finish(Database.BatchableContext BC){

List<String> toAddresses = new List<String>();
// Add email string to List
toAddresses.add('marnold@communispace.com');
String subject = 'Batch class run complete';
String body = '';

Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();

mail.setToAddresses(toAddresses);

mail.setSenderDisplayName('Salesforce Outbound Notification');
mail.setSubject(subject);
mail.setPlainTextBody(body);
mail.setUseSignature(false);

Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });

}