function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
VijayNiVijayNi 

Line: 4, Column: 14 Method does not exist or incorrect signature: void sendMail(String, String, String) from the type EmailManager

Hi All,

I  am getting below error can you help me what is the issue here ?


public class Emailsample 
{
     public static void sendMail(String address, String subject, String body) {
        Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
        String[] toAddresses = new String[] {address};
        mail.setToAddresses(toAddresses);
        mail.setSubject(subject);
        mail.setPlainTextBody(body);
        Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
    }
}

Passing values through Anonymous Window



String address ='vijayummeda35@gmail.com';
String subject ='Speaker confirmation for the session';
String body ='thank you for speaking at the conference really appericated';
EmailManager.sendMail(address, subject, body);
    
Best Answer chosen by VijayNi
SwethaSwetha (Salesforce Developers) 
HI Vijay,
Can you confirm the error you are seeing is "Variable does not exist: EmailManager" ?

If so, please change your apex class name from Emailsample to EmailManager

Your class should be 
public class EmailManager
{
     public Static void sendMail(String address, String subject, String body) {
        Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
        String[] toAddresses = new String[] {address};
        mail.setToAddresses(toAddresses);
        mail.setSubject(subject);
        mail.setPlainTextBody(body);
        Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
    }
}

Hope this helps you. Please mark this answer as best so that others facing the same issue will find this information useful. Thank you