在我看来,下面的片段应该可以工作,但是“mp.getBodyPart(1).getContent().toString()”返回
com.sun.mail.util.BASE64DecoderStream@44b07df8
而不是附件的内容。
public class GMailParser {
public String getParsedMessage(Message message) throws Exception {
try {
Multipart mp = (Multipart) message.getContent();
String s = mp.getBodyPart(1).getContent().toString();
if (s.contains("pattern 1")) {
return "return 1";
} else if (s.contains("pattern 2")) {
return "return 2";
}
...