How to Email Extent Report in Selenium WebDriver

Profile picture for user arilio666
Submitted by arilio666 on

To email an Extent Report generated by Selenium WebDriver, you can use the following steps:

  • Generate the Extent Report using Selenium WebDriver and save it to a local directory.
  • Use a Java email library, such as apache commons mail, to create an email message.
  • Attach the Extent Report file to the email message using the attachment functionality provided by the email library.
  • Specify the recipient's email address, subject, and body of the email message.
  • Use an email provider like Gmail or Yahoo to send the email message.

EmailAttachment attachment = new EmailAttachment();


        attachment.setDescription(" Test Execution Report");

        // Create the email message
        MultiPartEmail email = new MultiPartEmail();
        email.setAuthenticator(new DefaultAuthenticator("your email", "authentication_code"));
        email.addTo("toemail", "Test");
        email.setFrom("from email", "Me");
        email.setSubject("Automation Test Execution Report");
        email.setMsg("Automation Test Execution Report");

  • First, we use the apache commons mail library and set the path of the extent report.
  • Then we put the description and then used the multipart email library.
  • Here we set the SMTP port and other Gmail authentication tokens and emails.
  • Set the from mail and to mail accordingly.
  • Finally, attach the attachment and send the mail.


This is a simple and effective way of sending a freshly generated extent report through mail.