Modifying a message and copying to another folder
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   venkat_subramanian
Posted On:   Wednesday, May 9, 2001 06:28 PM

Using IMAP, how would you modify an existing 'message text' of a message in a folder, and copy the resulting message to another folder. The folders were open with READ_WRITE permission and only one session was opening them at a time. To modify a message, When I do Message message[] = folder.getMessage(); Message m = folder.getMessage(1); m.setText("dfjfhsfshdfljdss"); I am always getting javax.mail.IllegalWriteException: IMAPMessage is read-only at com.sun.mail.imap.IMAPMessage.setDataHandler(IMAPMessage.java:519) at javax.mail.internet.MimeMessage.setContent(MimeMessage.java:1300) at javax.mail.internet.MimeBodyPart.setText(MimeBodyPart.java:817)    More>>

Using IMAP, how would you modify an existing 'message text' of a message in a folder, and copy the resulting message to another folder. The folders were open with READ_WRITE permission and only one session was opening them at a time.


To modify a message, When I do
Message message[] = folder.getMessage();
Message m = folder.getMessage(1);
m.setText("dfjfhsfshdfljdss");



I am always getting


javax.mail.IllegalWriteException: IMAPMessage is read-only
at com.sun.mail.imap.IMAPMessage.setDataHandler(IMAPMessage.java:519)
at javax.mail.internet.MimeMessage.setContent(MimeMessage.java:1300)
at javax.mail.internet.MimeBodyPart.setText(MimeBodyPart.java:817)
at javax.mail.internet.MimeMessage.setText(MimeMessage.java:1333)
at javax.mail.internet.MimeMessage.setText(MimeMessage.java:1321)




I think the message cannot be changed, since it might be read only by design. Is copying all the properties of the message, and recreating in the destination folder the only solution.

Any code snippets might help.

   <<Less

Re: Modifying a message and copying to another folder

Posted By:   Tim_Boudreau  
Posted On:   Thursday, May 10, 2001 09:52 AM

Yes, IMAP does not support rewriting messages. You need to copy the message, modify the copy, delete the original and then append the copy to the originating folder. Note that its UID will change.
About | Sitemap | Contact