I've designed a very basic trigger that is meant to send me an email when a financial field on Opportunities is not blank. The code has no errors, and when I run my test class, it achieves 100% pass. However, when I go to test this out live, I never receive an email. I played around with After Insert and Before Update, but no dice. I'm not sure where else to look - help!


trigger FinancialErrorAssistant on Opportunity (after update) {
     //Trigger should continue only if the Financial sync error field is blank. 
     List <opportunity> Finance_Info = [Select Id, Finance_Sync_Error__c, AccountId, Bill_To_Account__c
                      From Opportunity];

    if(opportunity.Finance_Sync_Error__c != NULL){
        String[] toAddresses = new String[] {'[email protected]'};
        Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
        mail.setReplyTo('[email protected]');
        mail.setSenderDisplayName('Salesforce Support');
        mail.setPlainTextBody('A wild Finance error appears! ' + Finance_Sync_Error__c );

P.S. I know my governor limits are not on point, still learning!

  • are you running this in Sandbox. Then set email deliverability to ALL email. Commented Aug 22, 2016 at 16:59
  • 1
    That was my first thought as well, it's already set to "All". But thank you for the suggestion! Commented Aug 22, 2016 at 17:01
  • did you check debug and email invocation in debug And where do you declare this Opportunity? Commented Aug 22, 2016 at 17:02

1 Answer 1


You have to actually call Messaging.sendEmail. For example:

Messaging.sendEmail(new List<Messaging.SingleEmailMessage> { mail });

In regards to governor limits, you only get 10 invocations of the above method in a single transaction, so just call the send method outside any loops. You can build the list and then send the emails once the list is complete.

  • 1
    -Head Desk- Wow. I can't believe I just spent two hours looking at this and didn't even call the process, amateur mistake. Thank you, it works! Commented Aug 22, 2016 at 17:06
  • @DanielSassone Glad I could help! Don't forget, if this answer addressed your problem, you can accept it by clicking on the check mark/tick to the left of the answer, turning it green.
    – Adrian Larson
    Commented Aug 22, 2016 at 17:09
  • 1
    I absolutely will! It has a time limit on it before I can accept it. Commented Aug 22, 2016 at 17:11
  • Gotcha. I thought it was ten minutes, but I guess I was wrong and it's actually fifteen. Cheers!
    – Adrian Larson
    Commented Aug 22, 2016 at 17:12

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .