This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell 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


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: 42022
    
  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: 19697
    
  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
 
Don't get me started about those stupid light bulbs.
 
subject: Capture javamail error to file