KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I don't know why I'm getting the following exception when reading a mail with an attachment file from mail server: Exception in thread "main" javax.mail.MessagingException: Missing start boundary at javax.mail.internet.MimeMultipart.parsebm<MimeMultipart.java:872) at javax.mail.internet.MimeMultipart.parse<MimeMultipart.java:493) at javax.mail.internet.MimeMultipart.getCount<MimeMultipart.java:240) at GetParts.handleMultipart(GetParts.java:57) at GetParts.main(GetParts.java:42) The file which I'm using to read those messages is: import java.io.*; import java.util.Properties; import javax.mail.*; import javax.mail.internet.*; public class GetParts { public static void main (String args[]) throws Exception { String host = args[0]; String username = args[1]; String password = args[2]; // Get session Properties props=new Properties(); props.put("mail.mime.multipart.ignoremissingboundaryparamete",true); Session session = Session.getInstance( props, null); ContentType ct=new ContentType(); // Get the store Store store = session.getStore("pop3"); store.connect(host, username, password); // Get folder Folder folder = store.getFolder("INBOX"); folder.open(Folder.READ_ONLY); BufferedReader reader = new BufferedReader ( new InputStreamReader(System.in)); // Get directory Message message[] = folder.getMessages(); for (int i=0, n=message.length; i<n; i++) { System.out.println(i + ": " + message[i].getFrom()[0] + "\t" + message[i].getSubject()); //message[i].setHeader("Content-Type","multipart/mixed"); System.out.println("Do you want to get the content? [YES to read/QUIT to end]"); String line = reader.readLine(); if ("YES".equals(line)) { Object content = message[i].getContent(); if (content instanceof Multipart)
Tags (comma-separated)
Save Edits
Cancel