I am trying to get the contents of an html email including the tags etc. right now my code only returns the texts.this is my code:
Store store = session.getStore("pop3");
store.connect(host, username, passwoed);
Folder folder = store.getFolder("Inbox");
if (!folder.exists()) {
System.out.println("No INBOX...");
System.exit(0);
}
folder.open(Folder.READ_WRITE);
Message[] msg = folder.getMessages();
for (int i = msg.length - 1; i > 0; i--) {
String sent1 = df.format(sent);
sent1 = sent1.trim();
int index11 = sent1.indexOf(DateTime);
if (index11 != -1) {
String to = InternetAddress.toString(msg[i].getRecipients(Message.RecipientType.TO));
String s1 = "";
try {
Multipart multipart = (Multipart) msg[i].getContent();
for (int x = 0; x < multipart.getCount(); x++) {
BodyPart bodyPart = multipart.getBodyPart(x);
String disposition = bodyPart.getDisposition();
if (disposition != null && (disposition.equals(BodyPart.ATTACHMENT))) {
DataHandler handler = bodyPart.getDataHandler();
s1 = (String) bodyPart.getContent();
} else {
s1 = (String) bodyPart.getContent();
}
}
}
}
any help would be appreciated.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…