File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Other JSE/JEE APIs and the fly likes Capture javamail error to file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Other JSE/JEE APIs
Bookmark "Capture javamail error to file" Watch "Capture javamail error to file" New topic
Author

Capture javamail error to file

divya kundapur
Ranch Hand

Joined: Aug 21, 2007
Posts: 110

How can i store the javamail error to a file. I m sending mass email and would like to store the error when the email could not be delivered.


SCJP - 5.0
Freddy Wong
Ranch Hand

Joined: Sep 11, 2006
Posts: 959

Just catch the exception thrown and log it into a file.


SCJP 5.0, SCWCD 1.4, SCBCD 1.3, SCDJWS 1.4
My Blog
divya kundapur
Ranch Hand

Joined: Aug 21, 2007
Posts: 110
Freddy Wong wrote:Just catch the exception thrown and log it into a file.


Thank you, i did that just now, but the issue now is, suppose i have one email id out of 5 which javamail was not able to deliver to, it does not write to the file which one it is. and also it does not send out mails to any of the other email ids.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42356
    
  64
If you need one-by-one error handling you may have to send out the mails individually, instead of all in one go.


Ping & DNS - my free Android networking tools app
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19723
    
  20

Freddy Wong wrote:Just catch the exception thrown and log it into a file.

A logging framework like Log4J can really help with that. Using a FileAppender (possibly a RollingFileAppender), and using logger.error("message", exception) works like a charm.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Capture javamail error to file