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
Princes91221Princes91221 

Unexpected token 'body'

Hello,

I'm trying to send mail using apex class.

While I'm executing via Execute Anonymous Apex with Editors Content it throws an error stating "Unexpected token 'body' on line #3".

Below I'm pasting my code.

List<String> address = new List<String> { 'prince.sharma930@gmail.com', 'rahuls91221@gmail.com' };
String subject = 'Topcoder Challenge Sample Mail';
String body = 'Hi, Hope you stay safe and healthy during the COVID-19.;
WelcomeEmailProcessor.sendMail(address, subject, body);

Kindly Help.
Thanks you!
Shatrughna SalunkeShatrughna Salunke
Hi  Princes91221

Single quote missing in the sentence

List<String> address = new List<String> {'shatrughnasalunkhe@gmail.com', 'shatrughnasalunkhe@gmail.com'};
String subject = 'Topcoder Challenge Sample Mail';
String body = 'Hi, Hope you stay safe and healthy during the COVID-19.';
WelcomeEmailProcessor.sendMail(address, subject, body);

Regards,
Shatrughna
 
Princes91221Princes91221
Hi Shatrughna,
Actually i have closed with single quotes but while pasting here accidentally I deleted it before posting.
So is there any other way to solve that error, because I have been stuck at this from past 2-3 hours.

Kind regards,
Prince Sharma
Shatrughna SalunkeShatrughna Salunke
Hi Prince,

Could you please paste your WelcomeEmailProcessor apex class code so that we can debug it.

The below code seems to work fine for me. 

List<String> address = new List<String> {'shatrughnasalunkhe@gmail.com', 'shatrughnasalunkhe@gmail.com'};
String subject = 'Topcoder Challenge Sample Mail';
String body = 'Hi, Hope you stay safe and healthy during the COVID-19.';


Regards,
Shatrughna Salunke