|
@@ -787,18 +787,18 @@ public class EmailParseService {
|
|
|
log.warn("{} 邮件{} 没有获取到附件", folderName, emailTitle);
|
|
|
continue;
|
|
|
}
|
|
|
-
|
|
|
emailContentInfoDTOList.forEach(e -> {
|
|
|
e.setEmailType(emailType);
|
|
|
e.setSenderEmail(senderEmail);
|
|
|
});
|
|
|
emailMessageMap.put(uuidKey, emailContentInfoDTOList);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("{} 获取邮箱的邮件{} 报错,堆栈信息:{}", folderName, emailTitle, ExceptionUtil.stacktraceToString(e));
|
|
|
+ } finally {
|
|
|
if (log.isInfoEnabled()) {
|
|
|
log.info("{} 邮件{} 下载完成,总计耗时{} ms,文件内容如下\n {}", folderName,
|
|
|
emailTitle, System.currentTimeMillis() - start, emailContentInfoDTOList);
|
|
|
}
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("{} 获取邮箱的邮件{} 报错,堆栈信息:{}", folderName, emailTitle, ExceptionUtil.stacktraceToString(e));
|
|
|
}
|
|
|
}
|
|
|
if (this.readWriteSeen) {
|
|
@@ -815,8 +815,8 @@ public class EmailParseService {
|
|
|
if (StrUtil.isBlank(fileName)) {
|
|
|
return;
|
|
|
}
|
|
|
- if (fileName.contains("\"")) {
|
|
|
- fileName = fileName.replaceAll("\"", "");
|
|
|
+ if (fileName.contains("\"") || fileName.contains("\n")) {
|
|
|
+ fileName = fileName.replaceAll("\"", "").replaceAll("\n", "");
|
|
|
}
|
|
|
if (fileName.contains("=?")) {
|
|
|
fileName = MimeUtility.decodeText(fileName);
|
|
@@ -824,14 +824,14 @@ public class EmailParseService {
|
|
|
String disposition = part.getDisposition();
|
|
|
String contentType = part.getContentType();
|
|
|
|
|
|
- boolean attachmentFlag = StrUtil.endWithAny(fileName, ".zip", ".rar", ".pdf", ".png", ".jpg", ".docx");
|
|
|
+ boolean attachmentFlag = StrUtil.endWithAny(fileName, ".zip", ".rar", ".pdf", ".png", ".jpg", ".docx", ".7z");
|
|
|
boolean isAttachment = attachmentFlag
|
|
|
|| Part.ATTACHMENT.equalsIgnoreCase(disposition)
|
|
|
|| (contentType != null && attachmentMimePrefixes.stream().anyMatch(prefix ->
|
|
|
StrUtil.startWithIgnoreCase(contentType, prefix)
|
|
|
));
|
|
|
if (!isAttachment) {
|
|
|
- log.warn("邮件 {} 未检测到pdf/zip/rar/png/jpg/docx类型的附件 (fileName={}, disposition={}, contentType={})",
|
|
|
+ log.warn("邮件 {} 未检测到pdf/zip/rar/7z/png/jpg/docx类型的附件 (fileName={}, disposition={}, contentType={})",
|
|
|
subject, fileName, disposition, contentType);
|
|
|
return;
|
|
|
}
|
|
@@ -840,7 +840,7 @@ public class EmailParseService {
|
|
|
String filePath = path + File.separator + account + File.separator + emailDateStr + File.separator;
|
|
|
// 压缩包重名时的后面的压缩包会覆盖前面压缩包的问题(不考虑普通文件)
|
|
|
String emailDate = DateUtil.format(sendDate, DateConst.YYYYMMDDHHMMSS24);
|
|
|
- String realName = (fileName.endsWith(".zip") || fileName.endsWith(".rar")) ? emailDate + fileName : fileName;
|
|
|
+ String realName = (fileName.endsWith(".zip") || fileName.endsWith(".rar") || fileName.endsWith(".7z")) ? emailDate + fileName : fileName;
|
|
|
File saveFile = FileUtil.file(filePath + realName);
|
|
|
if (!saveFile.exists()) {
|
|
|
if (!saveFile.getParentFile().exists()) {
|