{"id":6377,"date":"2025-08-13T12:48:50","date_gmt":"2025-08-13T07:18:50","guid":{"rendered":"https:\/\/www.testleaf.com\/blog\/?p=6377"},"modified":"2025-09-16T17:56:59","modified_gmt":"2025-09-16T12:26:59","slug":"automating-testng-report-emails-a-step-by-step-guide","status":"publish","type":"post","link":"https:\/\/www.testleaf.com\/blog\/automating-testng-report-emails-a-step-by-step-guide\/","title":{"rendered":"Automating TestNG Report Emails: A Step-by-Step Guide"},"content":{"rendered":"<div style=\"margin-top: 0px; margin-bottom: 0px;\" class=\"sharethis-inline-share-buttons\" ><\/div><!--[if lt IE 9]><script>document.createElement('audio');<\/script><![endif]-->\n<audio class=\"wp-audio-shortcode\" id=\"audio-6377-1\" preload=\"none\" style=\"width: 100%;\" controls=\"controls\"><source type=\"audio\/mpeg\" src=\"https:\/\/www.testleaf.com\/blog\/wp-content\/uploads\/2025\/08\/Automating-TestNG-Report-Emails-A-Step-by-Step-Guide.mp3?_=1\" \/><a href=\"https:\/\/www.testleaf.com\/blog\/wp-content\/uploads\/2025\/08\/Automating-TestNG-Report-Emails-A-Step-by-Step-Guide.mp3\">https:\/\/www.testleaf.com\/blog\/wp-content\/uploads\/2025\/08\/Automating-TestNG-Report-Emails-A-Step-by-Step-Guide.mp3<\/a><\/audio>\n<p>&nbsp;<\/p>\n<h3 aria-level=\"1\"><b><span data-contrast=\"none\">Introduction<\/span><\/b><span data-ccp-props=\"{&quot;134245418&quot;:true,&quot;134245529&quot;:true,&quot;335559738&quot;:480,&quot;335559739&quot;:0}\">\u00a0<\/span><\/h3>\n<p><span data-contrast=\"auto\">In modern <a href=\"https:\/\/www.testleaf.com\/blog\/ai-in-test-automation-a-comprehensive-guide\/\">test automation<\/a>, simply running tests is not enough \u2014 rapid communication of results is key. Emailing TestNG reports automatically ensures every stakeholder, from QA engineers to project managers, gets instant insights into test health. Whether you\u2019re monitoring daily regression runs or validating a new release, this automation saves time, prevents oversight, and keeps your CI\/CD pipeline efficient. By integrating report emailing into your Selenium TestNG framework, you not only accelerate feedback loops but also strengthen collaboration across teams.<\/span><span data-ccp-props=\"{&quot;134233117&quot;:false,&quot;134233118&quot;:false,&quot;201341983&quot;:0,&quot;335551550&quot;:0,&quot;335551620&quot;:0,&quot;335559738&quot;:0,&quot;335559739&quot;:200,&quot;335559740&quot;:276}\">\u00a0<\/span><\/p>\n<h2 aria-level=\"1\"><span class=\"ez-toc-section\" id=\"What_Youll_Learn\"><\/span><b><span data-contrast=\"none\">What You\u2019ll Learn<\/span><\/b><span data-ccp-props=\"{&quot;134245418&quot;:true,&quot;134245529&quot;:true,&quot;335559738&quot;:480,&quot;335559739&quot;:0}\">\u00a0<\/span><span class=\"ez-toc-section-end\"><\/span><\/h2><div id=\"ez-toc-container\" class=\"ez-toc-v2_0_82_2 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/www.testleaf.com\/blog\/automating-testng-report-emails-a-step-by-step-guide\/#What_Youll_Learn\" >What You\u2019ll Learn\u00a0<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/www.testleaf.com\/blog\/automating-testng-report-emails-a-step-by-step-guide\/#Prerequisites\" >Prerequisites\u00a0<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/www.testleaf.com\/blog\/automating-testng-report-emails-a-step-by-step-guide\/#Step-by-Step_Emailing_the_Report\" >Step-by-Step: Emailing the Report\u00a0<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/www.testleaf.com\/blog\/automating-testng-report-emails-a-step-by-step-guide\/#Handling_Gmail_SMTP_If_Using_Gmail\" >Handling Gmail SMTP (If Using Gmail)\u00a0<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/www.testleaf.com\/blog\/automating-testng-report-emails-a-step-by-step-guide\/#Folder_Structure_After_Execution\" >Folder Structure After Execution\u00a0<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/www.testleaf.com\/blog\/automating-testng-report-emails-a-step-by-step-guide\/#Running_from_CLI_or_CI_Tools\" >Running from CLI or CI Tools\u00a0<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/www.testleaf.com\/blog\/automating-testng-report-emails-a-step-by-step-guide\/#Want_to_Go_Next-Level\" >Want to Go Next-Level?\u00a0<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/www.testleaf.com\/blog\/automating-testng-report-emails-a-step-by-step-guide\/#FAQs\" >FAQs\u00a0<\/a><\/li><\/ul><\/nav><\/div>\n\n<p><span data-contrast=\"auto\">In this guide, you&#8217;ll learn how to:<\/span><br \/>\n<span data-contrast=\"auto\">&#8211; Configure <a href=\"https:\/\/www.testleaf.com\/blog\/learn-15-testng-annotations-for-enhanced-selenium-testing\/\">TestNG<\/a> to generate reports<\/span><br \/>\n<span data-contrast=\"auto\">&#8211; Write Java code to automatically email reports after test execution<\/span><br \/>\n<span data-contrast=\"auto\">&#8211; Use an SMTP server (Gmail or your organization\u2019s mail server)<\/span><br \/>\n<span data-contrast=\"auto\">&#8211; Attach emailable-report.html to the mail<\/span><span data-ccp-props=\"{}\">\u00a0<\/span><\/p>\n<h2 aria-level=\"1\"><span class=\"ez-toc-section\" id=\"Prerequisites\"><\/span><b><span data-contrast=\"none\">Prerequisites<\/span><\/b><span data-ccp-props=\"{&quot;134245418&quot;:true,&quot;134245529&quot;:true,&quot;335559738&quot;:480,&quot;335559739&quot;:0}\">\u00a0<\/span><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p><span data-contrast=\"auto\">Before you begin, ensure you have the following:<\/span><br \/>\n<span data-contrast=\"auto\">&#8211; A working Selenium + TestNG project<\/span><br \/>\n<span data-contrast=\"auto\">&#8211; Tests that generate test-output\/emailable-report.html<\/span><br \/>\n<span data-contrast=\"auto\">&#8211; JavaMail API added as a dependency<\/span><\/p>\n<p><a href=\"https:\/\/www.testleaf.com\/course\/selenium-automation-certification-training-course.html\"><img fetchpriority=\"high\" decoding=\"async\" class=\"aligncenter wp-image-5159 size-full\" src=\"https:\/\/www.testleaf.com\/blog\/wp-content\/uploads\/2025\/06\/Selenium.jpg\" alt=\"Selenium training in chennai\" width=\"2048\" height=\"512\" srcset=\"https:\/\/www.testleaf.com\/blog\/wp-content\/uploads\/2025\/06\/Selenium.jpg 2048w, https:\/\/www.testleaf.com\/blog\/wp-content\/uploads\/2025\/06\/Selenium-300x75.jpg 300w, https:\/\/www.testleaf.com\/blog\/wp-content\/uploads\/2025\/06\/Selenium-1024x256.jpg 1024w, https:\/\/www.testleaf.com\/blog\/wp-content\/uploads\/2025\/06\/Selenium-768x192.jpg 768w, https:\/\/www.testleaf.com\/blog\/wp-content\/uploads\/2025\/06\/Selenium-1536x384.jpg 1536w, https:\/\/www.testleaf.com\/blog\/wp-content\/uploads\/2025\/06\/Selenium-150x38.jpg 150w\" sizes=\"(max-width: 2048px) 100vw, 2048px\" \/><\/a><br \/>\n<span data-contrast=\"auto\">If using <a href=\"https:\/\/en.wikipedia.org\/wiki\/Apache_Maven\">Maven<\/a>, add this to your pom.xml:<\/span><span data-ccp-props=\"{}\">\u00a0<\/span><\/p>\n<blockquote><p><span data-contrast=\"auto\">&lt;dependency&gt;<\/span><br \/>\n<span data-contrast=\"auto\">\u00a0\u00a0\u00a0 &lt;groupId&gt;com.sun.mail&lt;\/groupId&gt;<\/span><br \/>\n<span data-contrast=\"auto\">\u00a0\u00a0\u00a0 &lt;artifactId&gt;javax.mail&lt;\/artifactId&gt;<\/span><br \/>\n<span data-contrast=\"auto\">\u00a0\u00a0\u00a0 &lt;version&gt;1.6.2&lt;\/version&gt;<\/span><br \/>\n<span data-contrast=\"auto\">&lt;\/dependency&gt;<\/span><span data-ccp-props=\"{}\">\u00a0<\/span><\/p><\/blockquote>\n<h2 aria-level=\"1\"><span class=\"ez-toc-section\" id=\"Step-by-Step_Emailing_the_Report\"><\/span><b><span data-contrast=\"none\"><a href=\"https:\/\/www.testleaf.com\/blog\/step-by-step-approach-to-solve-any-programming-questions-in-your-qa-interview\/\">Step-by-Step<\/a>: Emailing the Report<\/span><\/b><span data-ccp-props=\"{&quot;134245418&quot;:true,&quot;134245529&quot;:true,&quot;335559738&quot;:480,&quot;335559739&quot;:0}\">\u00a0<\/span><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<h5 aria-level=\"2\"><b><span data-contrast=\"none\">1. Create a Utility Class: EmailUtils.java<\/span><\/b><span data-ccp-props=\"{&quot;134245418&quot;:true,&quot;134245529&quot;:true,&quot;335559738&quot;:200,&quot;335559739&quot;:0}\">\u00a0<\/span><\/h5>\n<p><span data-contrast=\"auto\">Here\u2019s a sample EmailUtils.java code using JavaMail API:<\/span><span data-ccp-props=\"{}\">\u00a0<\/span><\/p>\n<blockquote><p><span data-contrast=\"auto\">import java.util.*;<\/span><br \/>\n<span data-contrast=\"auto\">import javax.mail.*;<\/span><br \/>\n<span data-contrast=\"auto\">import javax.mail.internet.*;<\/span><br \/>\n<span data-contrast=\"auto\">import java.io.*;<\/span><\/p>\n<p><span data-contrast=\"auto\">public class EmailUtils {<\/span><\/p>\n<p><span data-contrast=\"auto\">\u00a0\u00a0\u00a0 public static void sendReportByEmail() {<\/span><br \/>\n<span data-contrast=\"auto\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 final String username = &#8220;your-email@gmail.com&#8221;;<\/span><br \/>\n<span data-contrast=\"auto\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 final String password = &#8220;your-app-password&#8221;;<\/span><\/p>\n<p><span data-contrast=\"auto\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Properties props = new Properties();<\/span><br \/>\n<span data-contrast=\"auto\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 props.put(&#8220;mail.smtp.auth&#8221;, &#8220;true&#8221;);<\/span><br \/>\n<span data-contrast=\"auto\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 props.put(&#8220;mail.smtp.starttls.enable&#8221;, &#8220;true&#8221;);<\/span><br \/>\n<span data-contrast=\"auto\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 props.put(&#8220;mail.smtp.host&#8221;, &#8220;smtp.gmail.com&#8221;);<\/span><br \/>\n<span data-contrast=\"auto\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 props.put(&#8220;mail.smtp.port&#8221;, &#8220;587&#8221;);<\/span><\/p>\n<p><span data-contrast=\"auto\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Session session = Session.getInstance(props, new Authenticator() {<\/span><br \/>\n<span data-contrast=\"auto\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 protected PasswordAuthentication getPasswordAuthentication() {<\/span><br \/>\n<span data-contrast=\"auto\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 return new PasswordAuthentication(username, password);<\/span><br \/>\n<span data-contrast=\"auto\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 }<\/span><br \/>\n<span data-contrast=\"auto\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 });<\/span><\/p>\n<p><span data-contrast=\"auto\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 try {<\/span><br \/>\n<span data-contrast=\"auto\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Message message = new MimeMessage(session);<\/span><br \/>\n<span data-contrast=\"auto\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 message.setFrom(new InternetAddress(&#8220;your-email@gmail.com&#8221;));<\/span><br \/>\n<span data-contrast=\"auto\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 message.setRecipients(Message.RecipientType.TO, InternetAddress.parse(&#8220;recipient@example.com&#8221;));<\/span><br \/>\n<span data-contrast=\"auto\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 message.setSubject(&#8220;TestNG Report &#8211; &#8221; + new Date());<\/span><\/p>\n<p><span data-contrast=\"auto\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 BodyPart messageBodyPart = new MimeBodyPart();<\/span><br \/>\n<span data-contrast=\"auto\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 messageBodyPart.setText(&#8220;Please find the attached TestNG report.&#8221;);<\/span><\/p>\n<p><span data-contrast=\"auto\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Multipart multipart = new MimeMultipart();<\/span><br \/>\n<span data-contrast=\"auto\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 multipart.addBodyPart(messageBodyPart);<\/span><\/p>\n<p><span data-contrast=\"auto\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 MimeBodyPart attachmentPart = new MimeBodyPart();<\/span><br \/>\n<span data-contrast=\"auto\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 attachmentPart.attachFile(new File(&#8220;test-output\/emailable-report.html&#8221;));<\/span><br \/>\n<span data-contrast=\"auto\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 multipart.addBodyPart(attachmentPart);<\/span><\/p>\n<p><span data-contrast=\"auto\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 message.setContent(multipart);<\/span><br \/>\n<span data-contrast=\"auto\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Transport.send(message);<\/span><\/p>\n<p><span data-contrast=\"auto\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 System.out.println(&#8220;Email Sent Successfully.&#8221;);<\/span><br \/>\n<span data-contrast=\"auto\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 } catch (Exception e) {<\/span><br \/>\n<span data-contrast=\"auto\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 e.printStackTrace();<\/span><br \/>\n<span data-contrast=\"auto\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 }<\/span><br \/>\n<span data-contrast=\"auto\">\u00a0\u00a0\u00a0 }<\/span><br \/>\n<span data-contrast=\"auto\">}<\/span><span data-ccp-props=\"{}\">\u00a0<\/span><\/p><\/blockquote>\n<h4 aria-level=\"2\"><a href=\"https:\/\/www.testleaf.com\/course\/playwright.html\"><img decoding=\"async\" class=\"aligncenter wp-image-5709 size-full\" src=\"https:\/\/www.testleaf.com\/blog\/wp-content\/uploads\/2025\/07\/Playwright-online-class.png\" alt=\"Playwright automation testing\" width=\"2048\" height=\"512\" srcset=\"https:\/\/www.testleaf.com\/blog\/wp-content\/uploads\/2025\/07\/Playwright-online-class.png 2048w, https:\/\/www.testleaf.com\/blog\/wp-content\/uploads\/2025\/07\/Playwright-online-class-300x75.png 300w, https:\/\/www.testleaf.com\/blog\/wp-content\/uploads\/2025\/07\/Playwright-online-class-1024x256.png 1024w, https:\/\/www.testleaf.com\/blog\/wp-content\/uploads\/2025\/07\/Playwright-online-class-768x192.png 768w, https:\/\/www.testleaf.com\/blog\/wp-content\/uploads\/2025\/07\/Playwright-online-class-1536x384.png 1536w, https:\/\/www.testleaf.com\/blog\/wp-content\/uploads\/2025\/07\/Playwright-online-class-150x38.png 150w\" sizes=\"(max-width: 2048px) 100vw, 2048px\" \/><\/a><\/h4>\n<h4 aria-level=\"2\"><b><span data-contrast=\"none\">2. Trigger It After Test Execution<\/span><\/b><span data-ccp-props=\"{&quot;134245418&quot;:true,&quot;134245529&quot;:true,&quot;335559738&quot;:200,&quot;335559739&quot;:0}\">\u00a0<\/span><\/h4>\n<p><span data-contrast=\"auto\">Call the utility from an @AfterSuite method in your base test class:<\/span><span data-ccp-props=\"{}\">\u00a0<\/span><\/p>\n<blockquote><p><span data-contrast=\"auto\">@AfterSuite<\/span><br \/>\n<span data-contrast=\"auto\">public void sendReport() {<\/span><br \/>\n<span data-contrast=\"auto\">\u00a0\u00a0\u00a0 EmailUtils.sendReportByEmail();<\/span><br \/>\n<span data-contrast=\"auto\">}<\/span><span data-ccp-props=\"{}\">\u00a0<\/span><\/p><\/blockquote>\n<h2 aria-level=\"1\"><span class=\"ez-toc-section\" id=\"Handling_Gmail_SMTP_If_Using_Gmail\"><\/span><b><span data-contrast=\"none\">Handling Gmail SMTP (If Using Gmail)<\/span><\/b><span data-ccp-props=\"{&quot;134245418&quot;:true,&quot;134245529&quot;:true,&quot;335559738&quot;:480,&quot;335559739&quot;:0}\">\u00a0<\/span><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p><span data-contrast=\"auto\">If you&#8217;re using Gmail:<\/span><br \/>\n<span data-contrast=\"auto\">1. Enable 2-Step <a href=\"https:\/\/www.testleaf.com\/blog\/verification-and-validation-in-software-testing\/\">Verification<\/a><\/span><br \/>\n<span data-contrast=\"auto\">2. Go to Google Account \u2192 Security \u2192 App Passwords<\/span><br \/>\n<span data-contrast=\"auto\">3. Generate an app-specific password (e.g., for &#8220;Mail&#8221;)<\/span><br \/>\n<span data-contrast=\"auto\">4. Use this app password in your code (not your regular Gmail password)<\/span><span data-ccp-props=\"{}\">\u00a0<\/span><\/p>\n<h2 aria-level=\"1\"><span class=\"ez-toc-section\" id=\"Folder_Structure_After_Execution\"><\/span><b><span data-contrast=\"none\">Folder Structure After Execution<\/span><\/b><span data-ccp-props=\"{&quot;134245418&quot;:true,&quot;134245529&quot;:true,&quot;335559738&quot;:480,&quot;335559739&quot;:0}\">\u00a0<\/span><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p><span data-contrast=\"auto\">After your test suite completes, TestNG generates:<\/span><br \/>\n<span data-contrast=\"auto\">&#8211; test-output\/emailable-report.html<\/span><br \/>\n<span data-contrast=\"auto\">&#8211; test-output\/index.html<\/span><\/p>\n<p><span data-contrast=\"auto\">You attach emailable-report.html in your email.<\/span><\/p>\n<p><span data-contrast=\"auto\"><strong>Optional<\/strong>: Rename the report with a timestamp for traceability.<\/span><span data-ccp-props=\"{}\">\u00a0<\/span><\/p>\n<h2 aria-level=\"1\"><span class=\"ez-toc-section\" id=\"Running_from_CLI_or_CI_Tools\"><\/span><b><span data-contrast=\"none\">Running from CLI or CI Tools<\/span><\/b><span data-ccp-props=\"{&quot;134245418&quot;:true,&quot;134245529&quot;:true,&quot;335559738&quot;:480,&quot;335559739&quot;:0}\">\u00a0<\/span><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p><span data-contrast=\"auto\">Use: mvn test<\/span><br \/>\n<span data-contrast=\"auto\">In Jenkins or other CI <a href=\"https:\/\/www.testleaf.com\/blog\/top-10-performance-testing-tools-in-2025\/\">tools<\/a>:<\/span><br \/>\n<span data-contrast=\"auto\">&#8211; Call EmailUtils.sendReportByEmail() from a post-build step or<\/span><br \/>\n<span data-contrast=\"auto\">&#8211; Include in the @AfterSuite of your base test class<\/span><span data-ccp-props=\"{}\">\u00a0<\/span><\/p>\n<h4 aria-level=\"1\"><b><span data-contrast=\"none\">Pro Tips<\/span><\/b><span data-ccp-props=\"{&quot;134245418&quot;:true,&quot;134245529&quot;:true,&quot;335559738&quot;:480,&quot;335559739&quot;:0}\">\u00a0<\/span><\/h4>\n<ol>\n<li><span data-contrast=\"auto\">Wait for the report file to be completely written<\/span><\/li>\n<li><span data-contrast=\"auto\">\u00a0Validate file path before attaching<\/span><\/li>\n<li><span data-contrast=\"auto\">\u00a0Compress large reports<\/span><\/li>\n<li><span data-contrast=\"auto\">\u00a0Attach logs\/screenshots if needed<\/span><\/li>\n<li><span data-contrast=\"auto\">\u00a0Use CC\/BCC wisely<\/span><span data-ccp-props=\"{}\">\u00a0<\/span><\/li>\n<\/ol>\n<p><img decoding=\"async\" class=\"aligncenter size-full wp-image-6379\" src=\"https:\/\/www.testleaf.com\/blog\/wp-content\/uploads\/2025\/08\/Pro-Tips.png\" alt=\"Pro Tips\" width=\"1920\" height=\"1080\" srcset=\"https:\/\/www.testleaf.com\/blog\/wp-content\/uploads\/2025\/08\/Pro-Tips.png 1920w, https:\/\/www.testleaf.com\/blog\/wp-content\/uploads\/2025\/08\/Pro-Tips-300x169.png 300w, https:\/\/www.testleaf.com\/blog\/wp-content\/uploads\/2025\/08\/Pro-Tips-1024x576.png 1024w, https:\/\/www.testleaf.com\/blog\/wp-content\/uploads\/2025\/08\/Pro-Tips-768x432.png 768w, https:\/\/www.testleaf.com\/blog\/wp-content\/uploads\/2025\/08\/Pro-Tips-1536x864.png 1536w, https:\/\/www.testleaf.com\/blog\/wp-content\/uploads\/2025\/08\/Pro-Tips-150x84.png 150w\" sizes=\"(max-width: 1920px) 100vw, 1920px\" \/><\/p>\n<h2 aria-level=\"1\"><span class=\"ez-toc-section\" id=\"Want_to_Go_Next-Level\"><\/span><b><span data-contrast=\"none\">Want to Go Next-Level?<\/span><\/b><span data-ccp-props=\"{&quot;134245418&quot;:true,&quot;134245529&quot;:true,&quot;335559738&quot;:480,&quot;335559739&quot;:0}\">\u00a0<\/span><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p><span data-contrast=\"auto\">Enhancements you can consider:<\/span><br \/>\n<span data-contrast=\"auto\">&#8211; Send <a href=\"https:\/\/en.wikipedia.org\/wiki\/HTML\">HTML<\/a> content in body instead of just attaching<\/span><br \/>\n<span data-contrast=\"auto\">&#8211; Embed screenshots or summaries<\/span><br \/>\n<span data-contrast=\"auto\">&#8211; Use ExtentReports instead of basic TestNG<\/span><br \/>\n<span data-contrast=\"auto\">&#8211; Convert report to PDF and send<\/span><br \/>\n<span data-contrast=\"auto\">&#8211; Integrate with Slack, Teams, etc. via webhook<\/span><span data-ccp-props=\"{}\">\u00a0<\/span><\/p>\n<h3 aria-level=\"1\"><b><span data-contrast=\"none\">Conclusion<\/span><\/b><span data-ccp-props=\"{&quot;134245418&quot;:true,&quot;134245529&quot;:true,&quot;335559738&quot;:480,&quot;335559739&quot;:0}\">\u00a0<\/span><\/h3>\n<p>Automating TestNG report delivery transforms how teams respond to quality issues. It reduces manual effort, accelerates feedback loops, and ensures complete transparency in testing. <strong data-start=\"289\" data-end=\"420\">In <a href=\"https:\/\/www.testleaf.com\/course\/selenium-automation-certification-training-course.html\">Selenium automation testing<\/a>, <\/strong>this approach not only streamlines result sharing but also enhances collaboration across teams<strong data-start=\"289\" data-end=\"420\">.<\/strong> Once you\u2019ve mastered email automation, you can extend the process to include rich HTML dashboards, PDF reports, or even <a href=\"https:\/\/www.testleaf.com\/blog\/traditional-automation-testing-vs-ai-driven-testing\/\">AI-driven<\/a> analytics for proactive defect detection. In short, this is not just a time-saver \u2014 it\u2019s a quality culture enabler.<\/p>\n<h2 data-start=\"178\" data-end=\"230\"><span class=\"ez-toc-section\" id=\"FAQs\"><\/span><strong data-start=\"181\" data-end=\"230\">FAQs\u00a0<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<h6 data-start=\"232\" data-end=\"527\"><strong data-start=\"232\" data-end=\"272\">1. What is TestNG report automation?<\/strong><\/h6>\n<p data-start=\"232\" data-end=\"527\">TestNG report automation is the process of automatically generating and sending TestNG test execution results to stakeholders. This eliminates manual report sharing, speeds up communication, and ensures teams have instant visibility into test outcomes.<\/p>\n<h6 data-start=\"529\" data-end=\"905\"><strong data-start=\"529\" data-end=\"614\">2. How does automated TestNG report delivery help in Selenium automation testing?<\/strong><\/h6>\n<p data-start=\"529\" data-end=\"905\">In <strong data-start=\"620\" data-end=\"651\">Selenium automation testing<\/strong>, automated TestNG report delivery ensures that test results are instantly available to developers, testers, and managers. This accelerates defect identification, improves collaboration, and supports continuous integration and delivery (CI\/CD) pipelines.<\/p>\n<h6 data-start=\"907\" data-end=\"979\"><strong data-start=\"907\" data-end=\"977\">3. What are the benefits of emailing TestNG reports automatically?<\/strong><\/h6>\n<ul data-start=\"980\" data-end=\"1170\">\n<li data-start=\"980\" data-end=\"1024\">\n<p data-start=\"982\" data-end=\"1024\">Reduces manual effort in sharing results<\/p>\n<\/li>\n<li data-start=\"1025\" data-end=\"1074\">\n<p data-start=\"1027\" data-end=\"1074\">Speeds up feedback loops for faster bug fixes<\/p>\n<\/li>\n<li data-start=\"1075\" data-end=\"1114\">\n<p data-start=\"1077\" data-end=\"1114\">Increases transparency across teams<\/p>\n<\/li>\n<li data-start=\"1115\" data-end=\"1170\">\n<p data-start=\"1117\" data-end=\"1170\">Supports better decision-making with real-time data<\/p>\n<\/li>\n<\/ul>\n<h6 data-start=\"1172\" data-end=\"1416\"><strong data-start=\"1172\" data-end=\"1230\">4. Can I customize TestNG reports before sending them?<\/strong><\/h6>\n<p data-start=\"1172\" data-end=\"1416\">Yes. You can enhance TestNG reports with HTML formatting, PDF exports, or even integrate <strong data-start=\"1322\" data-end=\"1345\">AI-driven analytics<\/strong> to highlight critical issues and trends before sending them via email.<\/p>\n<h6 data-start=\"1418\" data-end=\"1729\"><strong data-start=\"1418\" data-end=\"1490\">5. How do I integrate TestNG report emailing into my test framework?<\/strong><\/h6>\n<p data-start=\"1418\" data-end=\"1729\">You can use JavaMail API or similar email libraries in your test framework to send TestNG reports after execution. This can be part of your post-test actions in Selenium or integrated with CI\/CD tools like Jenkins for seamless delivery.<\/p>\n<h6 data-start=\"1731\" data-end=\"1996\"><strong data-start=\"1731\" data-end=\"1799\">6. Is it possible to send TestNG reports with visual dashboards?<\/strong><\/h6>\n<p data-start=\"1731\" data-end=\"1996\">Absolutely. Many teams extend their automation to include rich HTML dashboards or data visualizations along with standard reports, making it easier for stakeholders to interpret results quickly.<\/p>\n<h5><strong>We Also Provide Training In:<\/strong><\/h5>\n<ul>\n<li><a href=\"https:\/\/www.testleaf.com\/course\/selenium-automation-certification-training-course.html\"><strong>Advanced Selenium Training<\/strong><\/a><\/li>\n<li><a href=\"https:\/\/www.testleaf.com\/course\/playwright.html\"><strong>Playwright Training<\/strong><\/a><\/li>\n<li><a href=\"https:\/\/www.testleaf.com\/course\/genai-qa-engineers-training-course.html\"><strong>Gen AI Training<\/strong><\/a><\/li>\n<li><a href=\"https:\/\/www.testleaf.com\/course\/aws-cloud-architect-certification-training-course.html\"><strong>AWS Training<\/strong><\/a><\/li>\n<li><a href=\"https:\/\/www.testleaf.com\/course\/rest-api-testing-certification-training-course.html\"><strong>REST API Training<\/strong><\/a><\/li>\n<li><a href=\"https:\/\/www.testleaf.com\/course\/full-stack-developer-certification-training-course.html\"><strong>Full Stack Training<\/strong><\/a><\/li>\n<li><a href=\"https:\/\/www.testleaf.com\/course\/appium-mobile-automation-certification-training-course.html\"><strong>Appium Training<\/strong><\/a><\/li>\n<li><a href=\"https:\/\/www.testleaf.com\/course\/dev-ops-master-certification-training-course.html\"><strong>DevOps Training<\/strong><\/a><\/li>\n<li><a href=\"https:\/\/www.testleaf.com\/course\/apache-jmeter-testing-training-course.html\"><strong>JMeter Performance Training<\/strong><\/a><\/li>\n<\/ul>\n<h6><strong>Author\u2019s Bio<\/strong>:<\/h6>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-5813 alignleft\" src=\"https:\/\/www.testleaf.com\/blog\/wp-content\/uploads\/2025\/07\/Dilip.png\" sizes=\"(max-width: 250px) 100vw, 250px\" srcset=\"https:\/\/www.testleaf.com\/blog\/wp-content\/uploads\/2025\/07\/Dilip.png 250w, https:\/\/www.testleaf.com\/blog\/wp-content\/uploads\/2025\/07\/Dilip-150x150.png 150w, https:\/\/www.testleaf.com\/blog\/wp-content\/uploads\/2025\/07\/Dilip-96x96.png 96w\" alt=\"Dilip\" width=\"250\" height=\"250\" \/><\/p>\n<p>As a Senior SDET with 8+ years in testing and development, I build scalable automation platforms ensuring quality at speed. Passionate about mentoring and innovation, I equip teams with real-time solutions and high-impact frameworks, driving excellence through continuous learning. Let\u2019s shape the future of quality engineering together.<\/p>\n<p><strong>Dilipkumar Rajendran<\/strong><br \/>\nSenior SDET | Playwright &amp; Selenium Expert<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href=\"https:\/\/www.linkedin.com\/in\/dilip-kumar-v-r-633308150\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.testleaf.com\/blog\/wp-content\/uploads\/2025\/07\/linkedin.png\" alt=\"LinkedIn Logo\" width=\"28\" height=\"28\" \/><\/a><\/p>\n<p><span data-ccp-props=\"{}\">\u00a0<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>&nbsp; Introduction\u00a0 In modern test automation, simply running tests is not enough \u2014 rapid communication of results is key. Emailing TestNG reports automatically ensures every stakeholder, from QA engineers to project managers, gets instant insights into test health. Whether you\u2019re monitoring daily regression runs or validating a new release, this automation saves time, prevents oversight, &hellip;<\/p>\n<p class=\"read-more\"> <a class=\"\" href=\"https:\/\/www.testleaf.com\/blog\/automating-testng-report-emails-a-step-by-step-guide\/\"> <span class=\"screen-reader-text\">Automating TestNG Report Emails: A Step-by-Step Guide<\/span> Read More &raquo;<\/a><\/p>\n","protected":false},"author":1,"featured_media":6378,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"site-sidebar-layout":"default","site-content-layout":"default","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","theme-transparent-header-meta":"default","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","footnotes":""},"categories":[802,16],"tags":[70,29,130,91,803,804],"class_list":["post-6377","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-framework","category-selenium","tag-learn-selenium","tag-selenium","tag-selenium-coding","tag-selenium-testing","tag-selenium-testng","tag-testng-framwork"],"acf":[],"aioseo_notices":[],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/www.testleaf.com\/blog\/wp-json\/wp\/v2\/posts\/6377","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.testleaf.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.testleaf.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.testleaf.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.testleaf.com\/blog\/wp-json\/wp\/v2\/comments?post=6377"}],"version-history":[{"count":4,"href":"https:\/\/www.testleaf.com\/blog\/wp-json\/wp\/v2\/posts\/6377\/revisions"}],"predecessor-version":[{"id":6382,"href":"https:\/\/www.testleaf.com\/blog\/wp-json\/wp\/v2\/posts\/6377\/revisions\/6382"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.testleaf.com\/blog\/wp-json\/wp\/v2\/media\/6378"}],"wp:attachment":[{"href":"https:\/\/www.testleaf.com\/blog\/wp-json\/wp\/v2\/media?parent=6377"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.testleaf.com\/blog\/wp-json\/wp\/v2\/categories?post=6377"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.testleaf.com\/blog\/wp-json\/wp\/v2\/tags?post=6377"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}