I assume we're talking about
javax.mail.Store and
javax.mail.Session? From the docs, it looks like the problem may be that you're attempting to connect() the same Store twice, which is an error. (See inherited API for
Service. It's hard to tell though, because when you call getStore(), it's unspecified whether you get a new Store object or a preexisting one, which may already be open (or not). I'd recommend calling isConnected() before you connect, to see if it's necessary. You might also try adding a ConnectionListener to the Store to get additional info on what happens to that connection later:
Then, to get more info about whatever is going on:
You could also do something like this with a StoreListener, which may provide even more info. In fact you may find that the StoreListener sends you events when new mail arrives, which might mean you don't have to keep pinging the server, but instead wait for new events. That's just a wild guess though; quite possibly nothing like that will happen. But it might be worth investigating what StoreEvents there are, just to find out...
Also, I'm a bit confused by this line in your original code:
Aside from the fact that there's no declaration shown for isTimerAlive, the fact is that at the time this code is called, the timer
is alive. It's been set for repeated execution every 60 seconds - it's shouldn't be dying off just because it executes once. So I'm not sure what this variable is for, but it seems to indicate a misunderstanding of some sort.
Anyway, you may indeed need to try using Thread methods like interrupt() as DW suggest (or maybe even suspend() if you're really desparate, but I'd save that for a last resort). But I'd investifate other avenues first - seems like there's a good chance that you're just not connect()-ing in the right way. Good luck.
[ October 18, 2003: Message edited by: Jim Yingst ]