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
Aman Kumar 196Aman Kumar 196 

Method does not exist or incorrect signature: void toaddresses() from the type Messaging.SingleEmailMessage

I'm getting above error ,can someone help.


public class AssignmentEmail 
{    
    public string toEmail{get;set;}
    public List <string> Address;
    public string Subject{get;set;}
    public string Body{get;set;}
        
    public void SendEmail()
    {
        Messaging.SingleEmailMessage email= new Messaging.SingleEmailMessage();
        
        email.setSubject(Subject);
        email.setPlainTextBody(Body);
        Address= new List <string>();
        Address.add(toEmail); 
        email.toaddresses(Address);
        
    }
}
 
Best Answer chosen by Aman Kumar 196
David Zhu 🔥David Zhu 🔥
you may change the last line to 
email.setToAddresses(Address);

All Answers

David Zhu 🔥David Zhu 🔥
you may change the last line to 
email.setToAddresses(Address);
This was selected as the best answer
Aman Kumar 196Aman Kumar 196
Got it, Thank you!!