Removing Attachment from a Message
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

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

Re: Removing Attachment from a Message

Posted By:   Christopher_Koenigsberg  
Posted On:   Tuesday, July 8, 2003 06:53 AM

A mail store folder is not a general-purpose database... Send yourself a new edited copy by email, if you really need it there!

About | Sitemap | Contact