You need to sign in to do that
Don't have an account?
vepak
check whether setCcAddresses IS NULL OR NOT
Hi There,
I'm using visualforce page to specify to email address and cc email address to send email.
If both to address and cc address are specified my class handling it and working fine.
But cc email address field is blank in visualforce page my class coudn't handle and throws error
System.EmailException: SendEmail failed. First exception on row 0; first error: INVALID_EMAIL_ADDRESS, Invalid to address : : []
NOTE: I ASSUME ONLY ONE EMAIL IS SPECIFIED IN toemail FOR THIS EXAMPLE CODE
public String ccemail {get;set;} public String toemail {get;set;} public String subject {get;set;} public String body {get;set;} string[] ccaddress; if(ccemail!=NULL) ccaddress=ccemail.split(',', 0); else ccaddress=NULL; Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage(); mail.setUseSignature(false); mail.setToAddresses(new string[]{toemail}); mail.setCcAddresses(ccaddress); mail.setSubject(subject); mail.setHtmlBody(body); Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
Could you please help me in this.
Thanks,
Vamsi.
I think this will solve it, you can not check ccaddress != '' as ccaddress is an array
All Answers
Is there any problem if condition before the line where you are adding in CC address :
Or what exactly you are expecting?
Thanks
Ankit Arora
Blog | Facebook | Blog Page
I think this will solve it, you can not check ccaddress != '' as ccaddress is an array
Thanks Shashi, it worked.
Ankit, I think shashi is correct, I also tried same but ddn't worked.
Thanks a lot for your time.
I think I have corrected my answer, but good that you have the answer :)
Thanks
Ankit Arora
Blog | Facebook | Blog Page