Hi Keith,
Somehow I don’t think the problem
lies there but I’ll try it out.
Reason why I don’t think that’s
the problem…here’s my Threads run() method:
public void run (){
Resources.logger.info("MailReaderThread started.");
while(running){
Calendar cal = Calendar.getInstance();
int hour_of_day = cal.get(Calendar.HOUR_OF_DAY);
if (hour_of_day > 3 && hour_of_day < 20) { //only run between
4:00 - 19:00
try{
read();
} catch (Throwable t) {
Resources.logger.severe(t.toString());
MailSender.send(BulkCdrImporter.emailList,
"BulkCdrImporter.MailReaderThread Exception", "Exception:
"+t.toString());
break;
}
}
try{
Thread.sleep(60 * 1000); //1 minute
}catch (InterruptedException ie){}
}
Resources.logger.info("MailReaderThread shutting down");
}
…
The read() method connects to the store
and opens the appropriate folder and retrieves an array of Messages to process.
The problem happens when I receive a very
large message, the store/folder closes without expunging the message(s) that
have been set for deletion.
How will setting the poll interval to 5
mins stop the store/folder from closing unexpectedly?
Regards,
Enrico
Hi
Try
setting the interval for checking new mail to 5mins. This would allow for your
program to go through larger emails and do all of the stuff it has to do. One
minute might just be too short.
I
had a similar problem when I changed my intervals to 10min I had no more
problems.
Keith
Enrico,
I have quite a few applications that does the same thing. To
assist I need to see more. I also use a for loop and must admit that I seldom
get messages bigger than 5 MB.
To delete the message I use
msgs[i].setFlag(Flags.Flag.DELETED, true); where msgs is Message[] msgs.
Regards,
Gerhard Munro
From: [email protected] [mailto:[email protected]] On Behalf Of Enrico Goosen
Sent: 01 February 2006 01:11 PM
To: [email protected]
Subject: [CTJUG Forum] JavaMail bug
Hi
All,
Wonder
if anyone could help me with this problem.
I have
a mail reader thread that checks for emails every minute.
//
Retrieve the messages
Message[]
messages = folder.getMessages();
//
Loop over all of the messages
for
(int messageNumber = 0; messageNumber < messages.length; messageNumber++) {
…
//Process
message…save attachments to directory
…
message.setFlag(Flags.Flag.DELETED,
true);
}
//
Close connection, "expunging" the deleted messages
folder.close(true);
store.close();
Quite
often we receive a very large email (+/- 10 MB), and by the time it gets to the
next message in this for loop, the folder/store has already closed.
I’ve
added code to check if the store.isConnected before attempting to read the next
message, but this doesn’t fix the problem of the message not getting
deleted.
Because
the folder/store has closed prematurely the message doesn’t get deleted.
Is
there someway of preventing the folder/store from closing prematurely?
Otherwise,
how do I make sure that a message gets deleted?
Thanks,
Enrico Goosen
Software Developer
SAICOM TECHNOLOGY
TEL: +2721 555 0726
FAX: +2721 555 0821
CEL: +2783 305 5676
EMAIL: [EMAIL PROTECTED]
--
This e-mail and its contents are subject to the
South
African Medical Research Council
e-mail legal notice available at http://www.mrc.ac.za/about/EmailLegalNotice.html