dcsimg
IMAP: change message subject
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Stanislav_Davydov
Posted On:   Saturday, April 5, 2003 09:55 AM

Hello! I'm using IMAP protocol with JavaMail and I need to change subject of some existing message that I've request from some open folder: Folder inbox = store.getFolder("Inbox"); inbox.open(Folder.READ_WRITE); Message [] messages = inbox.getMessages(); for (int i = 0; i < messages.length; i++) { Message message = messages[i]; message.setSubject(message.getSubject() + "[" + i + "]"); } inbox.close(false); But I've got an exception: javax.mail.IllegalWriteException: IMAPMessage is read-only. So teh question is: Is it possible to change of subject of existing message in folder?    More>>

Hello!



I'm using IMAP protocol with JavaMail and I need to change subject of some existing message that I've request from some open folder:


			
Folder inbox = store.getFolder("Inbox");
inbox.open(Folder.READ_WRITE);
Message [] messages = inbox.getMessages();
for (int i = 0; i < messages.length; i++) {
Message message = messages[i];
message.setSubject(message.getSubject() + "[" + i + "]");
}
inbox.close(false);


But I've got an exception:
javax.mail.IllegalWriteException: IMAPMessage is read-only.



So teh question is: Is it possible to change of subject of existing message in folder?



Thank you in advance!
   <<Less

Re: IMAP: change message subject

Posted By:   shiladitya_sircar  
Posted On:   Thursday, November 6, 2003 07:36 AM

It is possible to change the subject. The reason why you have that exception is because you are operating on the current message. All you have to do is create another message from the current message and then operate on the new msg. This was you can do whatever you want on that message. Donot forget to save the message after all operations.


MimeMessage newmsg = new MimeMessage((MimeMessage) messages[i]);

Then operate on this message.
About | Sitemap | Contact