use of com.sun.mail.imap.IMAPNestedMessage in project vcell by virtualcell.
the class ListservMail method readMultiPart.
private static void readMultiPart(Multipart mp, int partNum, int size) throws Exception {
for (int j = 0; j < mp.getCount(); j++) {
Part part = mp.getBodyPart(j);
// Enumeration<Header> enumHeaders = part.getAllHeaders();
// while(enumHeaders.hasMoreElements()){
// Header h = enumHeaders.nextElement();
// System.out.println(h.getName()+" "+h.getValue());
// }
Object obj = null;
try {
obj = part.getContent();
} catch (UnsupportedEncodingException uce) {
obj = getStringFromStream(part.getInputStream(), part.getSize());
}
if ((obj instanceof IMAPNestedMessage)) {
readMessage(((IMAPMessage) obj), j, part.getSize());
} else if (obj instanceof IMAPInputStream) {
String s = getStringFromStream(((IMAPInputStream) obj), part.getSize());
System.out.println("stream content= " + s.length() + " " + size + " " + s.contains("@") + " disp=" + part.getDisposition() + " type=" + part.getContentType() + " descr=" + part.getDescription());
// DataInputStream dis = new DataInputStream(((IMAPInputStream)obj));
// byte[] bytes = new byte[size];
// dis.readFully(bytes);
// String s = new String(bytes);
// System.out.println("stream content= "+s.length()+" "+size+" "+s.contains("@")+" disp="+part.getDisposition()+" type="+part.getContentType()+" descr="+part.getDescription());
// dis.close();
} else if ((obj instanceof Multipart)) {
readMultiPart(((Multipart) obj), j, part.getSize());
} else if ((obj instanceof String)) {
String s = (String) obj;
Matcher matcher = pattern.matcher(s);
while (matcher != null && matcher.find()) {
MatchResult matchResult = matcher.toMatchResult();
String email = matchResult.group();
System.out.println(email);
bouncedEMails.add(email);
}
System.out.println("string content= " + s.length() + " " + size + " " + s.contains("@") + " disp=" + part.getDisposition() + " type=" + part.getContentType() + " descr=" + part.getDescription());
} else {
System.out.println("-----TBI part " + partNum + "\n" + obj.getClass().getName());
}
}
}
Aggregations