I know this question is asked before and could found in the below links, (I am posting this as I want to post my code with some changes to the solutions provided in the below links.)
PlainText email doesn't line break as expected
Send Email with the body formatted
I found the following code in a mentioned links above and tried though it doesn't work, What am I doing wrong here?
String plainTextBody = '';
plainTextBody += 'Confirmed Late Delivery is changed to unticked \n';
plainTextBody += 'Delivered Status is changed to a value that is not Delivered Late \n';
plainTextBody += 'Late Code is changed \n';
plainTextBody += 'or Late Code Subcategory is changed \n\n';
String[] toRecipients = new List<String> {'hasantha@com.au'};
String[] ccRecipients = new String[] {};
String[] bccRecipients = new String[] {};
String subject = 'test sub';
String body = plainTextBody;
Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
Messaging.reserveSingleEmailCapacity(1);
email.setToAddresses(toRecipients);
email.setCcAddresses(ccRecipients);
email.setbccAddresses(bccRecipients);
email.setSubject(subject);
email.setPlainTextBody(body);
System.debug(LoggingLevel.INFO,'** entered sendEmail, to:' + toRecipients + ' cc:' + ccRecipients + ' bcc:' + bccRecipients + ' subject:' + subject + ' body:' + body);
Messaging.sendEmail(new Messaging.SingleEmailMessage[] {email});
Below is the content of the received email
Confirmed Late Delivery is changed to unticked Delivered Status is changed to a value that is not Delivered Late Late Code is changed or Late Code Subcategory is changed
Thanks in-advance!