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
Venkat Surendra BezawadaVenkat Surendra Bezawada 

System.EmailException: SendEmail failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Either the plain text body or html body must be supplied

I am getting below error while doing trail head
Step not yet complete... here's what's wrong: 
There was an unexpected error in your org which is preventing this assessment check from completing: System.EmailException: SendEmail failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Either the plain text body or html body must be supplied.: [] 
Note: you may run into errors if you've skipped previous steps.
Amit Chaudhary 8Amit Chaudhary 8
Please try below code.
public class EmailManager {

    // Public method
    public void sendMail(String address, String subject, String body) {
        // Create an email message object
        Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
        String[] toAddresses = new String[] {address};
        mail.setToAddresses(toAddresses);
        mail.setSubject(subject);
        mail.setPlainTextBody(body);
        // Pass this email message to the built-in sendEmail method 
        // of the Messaging class
        Messaging.SendEmailResult[] results = Messaging.sendEmail(
                                 new Messaging.SingleEmailMessage[] { mail });
        
        // Call a helper method to inspect the returned results
        inspectResults(results);
    }
    
    // Helper method
    private static Boolean inspectResults(Messaging.SendEmailResult[] results) {
        Boolean sendResult = true;
        
        // sendEmail returns an array of result objects.
        // Iterate through the list to inspect results. 
        // In this class, the methods send only one email, 
        // so we should have only one result.
        for (Messaging.SendEmailResult res : results) {
            if (res.isSuccess()) {
                System.debug('Email sent successfully');
            }
            else {
                sendResult = false;
                System.debug('The following errors occurred: ' + res.getErrors());                 
            }
        }
        
        return sendResult;
    }

}


 
Paula Rae NelsonPaula Rae Nelson
I am getting the same error even though the emails are being sent correctly and the debug says success. 
Venkat Surendra BezawadaVenkat Surendra Bezawada
I am getting below error while using that code
There was an unhandled exception. Please reference ID: QELJTOSM. Error: Resque::TermException. Message: SIGTERM
Soumya behera 13Soumya behera 13
I am also getting the same error.  #Amit Chaudhary 8 , i have tried your code , even it resulting same error.  Not sure why its coming because while tesing it was working fine . I could able to get the email .
Marina FinotelliMarina Finotelli
I was getting a similar error eventhough I received the email everytime I executed the code.

What I found out was that the trailhead code is fine!
https://trailhead.salesforce.com/projects/salesforce_developer_workshop/steps/creating_apex_class

What I did that made it work perfectly was:
  • Close the developer console, reopen it and retry. If that still doesn't fix the problem, click the "Progress" tab at the bottom of the developer console, click the "Cancel All Deployments" button, and retry.
  • Changed API version from 39 to 37 (below the main tabs on develper console)
  • Setup-->Administer-->Email Administration-->Deliverability and change the setting from "System emails only" to "All Emails"