You need to sign in to do that
Don't have an account?

How to add new line to apex email body
Hello,
This is my apex email body in the code.
String body = 'Dear ' + con.firstname + ' ' + con.lastname + ', ';
body += 'Thank you for considering us for your on-going software development needs. We sincerely value the opinion of our customers, and we would love to hear your opinion on our services which would help us improve the same.Please take a few minutes to complete the Feedback form by visiting the link given below.' ;
body += 'Here’s the link https://appfeedback-developer-edition.na30.force.com/survey/?email='+con.email+'&fullname='+con.firstname+ +con.lastname
body += 'Best Regards,' ;
I want each of these lines on the new line.Currently it is displaying in email as.
Dear Tejas Wadke, Thank you for considering us for your on-going software development needs. We sincerely value the opinion of our customers, and we would love to hear your opinion on our services which would help us improve the same.Please take a few minutes to complete the Feedback form by visiting the link given below. Here’s the link https://appfeedback-developer-edition.na30.force.com/survey/?email=tejas.wadke@aress.com&fullname=TejasWadkeBest Regards,https://www.tester.com?fullname=con.firstname+con.lastname
This is my apex email body in the code.
String body = 'Dear ' + con.firstname + ' ' + con.lastname + ', ';
body += 'Thank you for considering us for your on-going software development needs. We sincerely value the opinion of our customers, and we would love to hear your opinion on our services which would help us improve the same.Please take a few minutes to complete the Feedback form by visiting the link given below.' ;
body += 'Here’s the link https://appfeedback-developer-edition.na30.force.com/survey/?email='+con.email+'&fullname='+con.firstname+ +con.lastname
body += 'Best Regards,' ;
I want each of these lines on the new line.Currently it is displaying in email as.
Dear Tejas Wadke, Thank you for considering us for your on-going software development needs. We sincerely value the opinion of our customers, and we would love to hear your opinion on our services which would help us improve the same.Please take a few minutes to complete the Feedback form by visiting the link given below. Here’s the link https://appfeedback-developer-edition.na30.force.com/survey/?email=tejas.wadke@aress.com&fullname=TejasWadkeBest Regards,https://www.tester.com?fullname=con.firstname+con.lastname
Hi,
You can use the setHtmlBody() method.
Example:
You can use New line character '\n' to display contentin separate lines.
Please find modified code and Let me know if that helps you.
Best Regards,
BALAJI
You can use the setHtmlBody() method and break tag '<br/>' when you want to display contentin separate lines.
Please find modified code and Let me know if that helps you.
String body = 'Your Attention Please! '+','+'<br/>';
body += 'Below Batch Job(s) are expiring in a week please take necessary action.'+'<br/>';
body += '<b>Batch Job name :<b/>'+ct.CronJobDetail.Name+' '+'<b>Batch Job start Date :</b>'+ct.StartTime+' '+'<b>Batch Job End Date : </b>'+ct.EndTime+'<br/>';
body +='Regards'+','+'\n Batch Monitoring'+'<br/>';
body +='<b>Internal Team mail id:</b>'+' '+'sf.internal@castandcrew.com'+'<br/>';
mail.setHtmlBody(body);
Best Regards,
Balu.