When running the following code I get this error message:
[Messaging.SingleEmailMessage].setToAddressof(List)
public class outboundemail1 {
public void sendMail(){
String[] toadd = new String[]{'[email protected]'};
String[] toCc = new String[]{'[email protected]'};
Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
email.setToAddress(toadd);
email.setCcAddresses(tocc);
email.setSubject('Hi from salesforce sender bhavani');
email.setPlainTextBody('Welcome to Salesforce Email for the first time');
Messaging.SingleEmailMessage email2=new Messaging.SingleEmailMessage();
email2.setToAddress(toadd);
email2.setSubject('HTML Body');
email2.setHTMLBody('<h1style="colour:green">Welcome to Salesforce Email for the first time</h1>');
email2.setSenderDisplayName('bhavani818584884');
Messaging.Email[] emails = new Messaging.Email[] {email,email2};
Messaging.SendEmail(emails);
}
}
This is the code of my visualforce page:
<apex:page OutboundEmail1 ot=new OutboundEmail1> ot.sendMais(); </apex:page>