hai,
I am trying to send emailable-report.html after my test execution is completed, but I am unable to get any reports…
When I run individual class file for receiving email able report It will work, but when I run in test suit I am unable to get…can any one please help me
please find the below email sent code
public static void main(String[] args) {
final String username = "nandini.ddfdf@semasoft.co.in";
final String password = "sdfsdfsfs";
Properties props = new Properties();
props.put("mail.smtp.auth", "true");
props.put("mail.smtp.starttls.enable", "true");
props.put("mail.smtp.host", "smtp.gmail.com");
props.put("mail.smtp.port", "587");
Session session = Session.getInstance(props,
new javax.mail.Authenticator() {
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(username, password);
}
});
try {
Message message = new MimeMessage(session);
message.setFrom(new InternetAddress("nandini.sddf@gmail.com"));
message.setRecipients(Message.RecipientType.TO,
InternetAddress.parse("nandini.sddd@gmail.com"));
message.setSubject("Testing Subject");
message.setText("Dear Mail Crawler,"
+ "\n\n No spam to my email, please!");
MimeBodyPart messageBodyPart2 = new MimeBodyPart();
String filename = "/Users/nandini/Documents/workspace/ios app/test-output/emailable-report.html";
DataSource source = new FileDataSource(filename);
messageBodyPart2.setDataHandler(new DataHandler(source));
messageBodyPart2.setFileName(filename);
Multipart multipart = new MimeMultipart();
multipart.addBodyPart(messageBodyPart2);
multipart.addBodyPart(messageBodyPart2);
message.setContent(multipart );
Transport.send(message);
System.out.println("Done");
} catch (MessagingException e) {
throw new RuntimeException(e);
}
}
}
below are the test suite
<test name="PDFbooks" >
<classes>
<class name="iosapp.PDFbooks" />
</classes>
</test>
<test name="EmailSent" >
<classes>
<class name="iosapp.EmailSent" ></class>
</classes>