Hi,
I am working on Module 24 for Hybrid Framework. I downloaded the latest code, but do not see Mail.Java file in it.
Can you please send the mail.java file?
I am a little confused whether to use the 'ZipAndSendMail' or directly use 'SendMail'?
I am getting an error in ZipAndSendMail file as seen in the screenshot.
When I try to run the SendMail file, I get following error. Not sure how to fix it. I checked online and tried to debug, but couldn't get solution:
Exception in thread "main" java.lang.NoClassDefFoundError: com/sun/mail/util/MailLogger
at javax.mail.Session.initLogger(Session.java:283)
at javax.mail.Session.<init>(Session.java:268)
at javax.mail.Session.getInstance(Session.java:304)
at com.Shree_Automate_Feb2019.mail.SendMail.sendMail(SendMail.java:126)
at com.Shree_Automate_Feb2019.mail.SendMail.main(SendMail.java:51)
Caused by: java.lang.ClassNotFoundException: com.sun.mail.util.MailLogger
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 5 more
Instructor
Ashish Thakur Replied on 18/03/2019
You're missing Java Mail library.
Please refer the link below,
https://stackoverflow.com/questions/16807758/java-lang-noclassdeffounderror-com-sun-mail-util-maillogger-for-junit-test-case
Thanks for your reply. I could resolve it with a minor change. I am now getting access denied problem on both gmail, yahoo, and my local corporate account. Not sure how to resolve this now:
javax.mail.MessagingException: IOException while sending message;
nested exception is:
java.io.FileNotFoundException: C:\Users\aagarwal\Desktop\AutomationFramework_2019\Shree_Automate_Feb2019\src\main\java\com\Shree_Automate_Feb2019\reports (Access is denied)
at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:1365)
at com.Shree_Automate_Feb2019.mail.zipAndSendEmail.sendMail(zipAndSendEmail.java:148)
at com.Shree_Automate_Feb2019.mail.zipAndSendEmail.main(zipAndSendEmail.java:63)
Caused by: java.io.FileNotFoundException: C:\Users\aagarwal\Desktop\AutomationFramework_2019\Shree_Automate_Feb2019\src\main\java\com\Shree_Automate_Feb2019\reports (Access is denied)
at java.io.FileInputStream.open0(Native Method)
at java.io.FileInputStream.open(Unknown Source)
at java.io.FileInputStream.<init>(Unknown Source)
at javax.activation.FileDataSource.getInputStream(Unknown Source)
at javax.activation.DataHandler.writeTo(Unknown Source)
at javax.mail.internet.MimeBodyPart.writeTo(MimeBodyPart.java:1694)
at javax.mail.internet.MimeBodyPart.writeTo(MimeBodyPart.java:996)
at javax.mail.internet.MimeMultipart.writeTo(MimeMultipart.java:561)
at com.sun.mail.handlers.multipart_mixed.writeTo(multipart_mixed.java:84)
at javax.activation.ObjectDataContentHandler.writeTo(Unknown Source)
at javax.activation.DataHandler.writeTo(Unknown Source)
at javax.mail.internet.MimeBodyPart.writeTo(MimeBodyPart.java:1694)
at javax.mail.internet.MimeMessage.writeTo(MimeMessage.java:1913)
at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:1315)
... 2 more
javax.mail.MessagingException: IOException while sending message;
nested exception is:
java.io.FileNotFoundException: C:\Users\aagarwal\Desktop\AutomationFramework_2019\Shree_Automate_Feb2019\src\main\java\com\Shree_Automate_Feb2019\reports (Access is denied)
at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:1365)
at com.Shree_Automate_Feb2019.mail.SendMail.sendMail(SendMail.java:184)
at com.Shree_Automate_Feb2019.mail.zipAndSendEmail.main(zipAndSendEmail.java:73)
Caused by: java.io.FileNotFoundException: C:\Users\aagarwal\Desktop\AutomationFramework_2019\Shree_Automate_Feb2019\src\main\java\com\Shree_Automate_Feb2019\reports (Access is denied)
at java.io.FileInputStream.open0(Native Method)
at java.io.FileInputStream.open(Unknown Source)
at java.io.FileInputStream.<init>(Unknown Source)
at javax.activation.FileDataSource.getInputStream(Unknown Source)
at javax.activation.DataHandler.writeTo(Unknown Source)
at javax.mail.internet.MimeBodyPart.writeTo(MimeBodyPart.java:1694)
at javax.mail.internet.MimeBodyPart.writeTo(MimeBodyPart.java:996)
at javax.mail.internet.MimeMultipart.writeTo(MimeMultipart.java:561)
at com.sun.mail.handlers.multipart_mixed.writeTo(multipart_mixed.java:84)
at javax.activation.ObjectDataContentHandler.writeTo(Unknown Source)
at javax.activation.DataHandler.writeTo(Unknown Source)
at javax.mail.internet.MimeBodyPart.writeTo(MimeBodyPart.java:1694)
at javax.mail.internet.MimeMessage.writeTo(MimeMessage.java:1913)
at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:1315)
... 2 more
Here is my .java file attached.
Instructor
Ashish Thakur Replied on 19/03/2019
java.io.FileNotFoundException: C:\Users\aagarwal\Desktop\AutomationFramework_2019\Shree_Automate_Feb2019\src\main\java\com\Shree_Automate_Feb2019\reports (Access is denied)
This exception comes up when the code is not able to access the particular file. Make sure it is not open somewhere else. Also, try using the IDE with admin privileges
I debugged the issue through other approach and resolved it. Thanks so much.