How Do I read multipart mail from IMAP Server
2 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Rajiv_Singh
Posted On:   Thursday, March 14, 2002 05:51 AM

Dear Friends
I am using Courier IMAP. I am working
to make full fledge mail
engine. I am able to send mail
as attachment and also I can read
mail. My problem is How do I
read the attachment Part.

Rajiv Singh

Re: How Do I read multipart mail from IMAP Server

Posted By:   Saravankumar_S  
Posted On:   Thursday, March 21, 2002 07:17 PM

Hi
First you write into a outputstream and from that you just read it.
Here I wrote few lines of code for your reference.

javax.mail.internet.MimeBodyPart part=(javax.mail.internet.MimeBodyPart)multipart.getBodyPart(p);
String filename=part.getFileName();
java.io.InputStream ins = part.getInputStream();
java.io.OutputStream ous =null;
javax.mail.Part Content=multipart.getBodyPart(p);
String disposition = Content.getDisposition();
if (disposition != null && (disposition.equals(Part.ATTACHMENT) || disposition.equals(Part.INLINE))) {

ous = getStreamToWriteFile(filename,msgid);
} else{
ous = getStreamToWriteFile(msgid+".body.txt",msgid);
}

int b=-1;
while((b = ins.read())!=-1){ous.write(b); }
ous.close();

Re: How Do I read multipart mail from IMAP Server

Posted By:   Jeff_Gay  
Posted On:   Sunday, March 17, 2002 05:21 AM

See the FAQ and demo applications.
About | Sitemap | Contact