SendEmail failed. First exception on row 0; first error: INVALID_EMAIL_ADDRESS, Invalid to address : : [] Error is in expression '{!sendEmail}' in component in page MyPage: Class.MyClass.sendEmail: line 408, column 1
Send Email code is as below
Messaging.SingleEmailMessage message = new Messaging.SingleEmailMessage();
message.saveAsActivity = false;
message.setOrgWideEmailAddressId(emailFromAddress);//emailFromAddress(string)-containing id
message.setCcAddresses(new String[]{emailCCAddress});//emailCCAddress(string)
message.setBccAddresses(new String[]{emailBCCAddress});//emailBCCAddress(string)
message.setSubject(emailSubject);//emailSubject(string)
message.setHtmlBody(emailBody); //emailBody(string)
message.setToAddresses(new String[]{emailToAddress.trim()}); //emailToAddress is a string containing '[email protected]'
//message.setToAddresses(new String[]{'[email protected]'}); //Tried this too still giving same error
Messaging.SendEmailResult[] mailResults = Messaging.sendEmail(new Messaging.SingleEmailMessage[]{message});// Line 408 where error occurs
Please help! i am facing this issue since long time. Tia