Read Multipart mail using Java Mail
by, 04-25-2012 at 11:04 PM (2848 Views)
Multipart messages could be read by javamail api which has been shown in this example. Multipart class object is created to read the multipart mail.
For composition of mails along with attachments, Multipart mail is being used now a days. One might attach the doc, images, zip files, xls etc. Mails that could be designed nicely are created by it.
Classes are provided by the Java Mail API so that Multipart messages could be created, sent or read. Java Mail api is used for creation of the mails along with attachments, in Java technologies.
Using the Multipart Class
How Multipart class could be used is shown in given code. Firstly Multipart class object is created so that to obtain body part & read/compose emails.
Then bodyPart content is read by the help of getContent() method.Java Code:Multipart multipart = (Multipart) msg[i].getContent();After that create BodyPart object BodyPart bodyPart = multipart.getBodyPart(x);