• Dan Carney 6
  • NEWBIE
  • 0 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 0
    Replies
Hi. I'm having trouble with one of the exercises in the Get Started with Apex Triggers module, where you call a Class Method from a Trigger.

Here is the trigger I created. 


trigger ExampleTrigger on Contact (after insert, after delete) {
    if (Trigger.isInsert) {
        Integer recordCount = Trigger.New.size();
        // Call a utility method from another class
        EmailManager.sendMail('dtcarney08@gmail.com', 'Trailhead Trigger Tutorial', 
                              recordCount + ' contact(s) were inserted.');
    }
    else if (Trigger.isDelete) {
        // Process after delete
    }
}

This calls on this public class called EmailManager

public with sharing class EmailManager{
    public static void sendMail(String[] addresses, String[] subjects, String[] messages) {
        Messaging.SingleEmailMessage [] emails = new Messaging.SingleEmailMessage[]{};
        Integer totalMails = addresses.size();
        for(Integer i=0; i < totalMails; i++){
            Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
            email.setSubject(subjects[i]);
            email.setToAddresses(new List<String> { addresses[i] });
            email.setPlainTextBody(messages[i]);
            emails.add(email);
        }
        Messaging.sendEmail(emails);
    }
}

However, there is a problem that shows up in the Developer Console that says “Method does not exist or incorrect signature: void sendMail (String, String, String) from the type EmailManager. I thought that I made the method static and I'm not sure what's wrong now. Any ideas of what's wrong?