This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
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 OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA 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: 41621
    
  55
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: 19684
    
  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
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Capture javamail error to file