reading pop3 mail
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Vijay_Jadhav
Posted On:   Thursday, February 28, 2008 03:16 AM

Hi,
I have done code for read text message from gmail pop3 mail server. That works fine. but i don't know how to read multipart, attachments from message. I want to write code for this also.
Please help me.

Re: reading pop3 mail

Posted By:   bharath_kumar  
Posted On:   Monday, March 17, 2008 08:03 AM



// Retrieve the Multipart object from the message

Multipart multipart = (Multipart)message.getContent();



// Loop over the parts of the email

for (int i=0; i


// Retrieve the next part

Part part = multipart.getBodyPart(i);



// Get the content type

String contentType=part.getContentType();



// Display the content type

System.out.println("Content: " + contentType);



// If the content is printable (ie. is text) then display
the message, line by line

if (contentType.startsWith("text/plain")) {



InputStream is = part.getInputStream();

BufferedReader br = new BufferedReader(new InputStreamReader(is));

String currentLine = null;



while ((currentLine=br.readLine()) != null) {

System.out.println(currentLine);

}

}


Hope this helps

About | Sitemap | Contact