Posted By:
Sujesh_Surendran
Posted On:
Tuesday, July 8, 2003 03:30 AM
Hello jguru's When I try to remove the attachment from a message using the below code i get an exception that imap is read only.Is there any possible way to do this with imap. code: Object obj=msg.getContent(); if(obj instanceof Multipart) { boolean remove = false; Multipart mp=(Multipart)obj; for(int j=0;j { BodyPart bp=mp.getBodyPart(j); String disposition=bp.getDisposition(); if(disposition!=null && (disposition.equalsIgnoreCase(Part.ATTACHMENT))) { filename=bp.getFileName(); remove = mp.removeBodyPart(bp); j--; } if(remove == true) { msg.saveChanges();
More>>
Hello jguru's
When I try to remove the attachment from a message using the below code i get an exception that imap is read only.Is there any possible way to do this with imap.
code:
Object obj=msg.getContent();
if(obj instanceof Multipart)
{
boolean remove = false;
Multipart mp=(Multipart)obj;
for(int j=0;j
{
BodyPart bp=mp.getBodyPart(j);
String disposition=bp.getDisposition();
if(disposition!=null && (disposition.equalsIgnoreCase(Part.ATTACHMENT)))
{
filename=bp.getFileName();
remove = mp.removeBodyPart(bp);
j--;
}
if(remove == true)
{
msg.saveChanges();
System.out.println("Attachment " + filename + " removed from the message");
}
else
System.out.println("No attachment in the bodypart("+ j +" )");
This exception is because i save the changes of the message back to the store.
Incase any other way exist pls let me know
Thanks in advance.
<<Less