You need to sign in to do that
Don't have an account?
Method does not exist or incorrect signature: [Messaging.SingleEmailMessage].setToAddress(String)
Hello
I am setting up an Apex Class that will be used for sending an email, but I get the error that is mentioned in the subject
Thanks for your help
public class sendEmail {
public String subject { get; set; }
public String body { get; set; }
private final Playlist__c playlist;
// Create a constructor that populates the Account object
public sendEmail() {
playlist = [select Name,id,Contact__r.Email from Playlist__c where id = :ApexPages.currentPage().getParameters().get('id')];
}
public Playlist__c getPlaylist() {
return playlist;
}
public PageReference send() {
// Define the email
Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
String address = playlist.Contact__r.Email;
// Sets the paramaters of the email
email.setSubject( subject );
email.setToAddresses( address);
email.setPlainTextBody( body );
// Sends the email
Messaging.SendEmailResult [] r =
Messaging.sendEmail(new Messaging.SingleEmailMessage[] {email});
return null;
}
}