【发布时间】:2019-10-27 01:56:04
【问题描述】:
我正在使用 apache 的 MimeMessageParser 来获取 MimeMessage。它还有另一个 电子邮件 类型的附件,其中包含正文内容和内嵌图像。我能够从 mimeMessage 获取电子邮件附件,并且可以成功地将其转换为 .msg 文件。
但是当我尝试打开 .msg 文件时,出现错误
我们无法打开“C:\local\1_file_ds.msg”。文件可能是 已经打开,或者您没有打开它的权限。
谁能帮我解决这个问题?我想将电子邮件附件转换为.msg 文件。
以下是我正在使用的代码。
List<DataSource> attachmentList = email.getAttachmentList();
int attachmentCount = 1;
try {
for (DataSource attachment : attachmentList) {
if (attachment.getContentType().equals("message/rfc822")) {
InputStream inputStream;
inputStream = attachment.getInputStream();
String destName = "C:\\local\\" + +attachmentCount + "_" + "file_ds" + ".msg";
File file = new File(destName);
FileUtils.copyInputStreamToFile(inputStream, file);
attachmentCount = attachmentCount + 1;
}
}
} catch (IOException e) {
e.printStackTrace();
}
【问题讨论】:
标签: java mime mime-message rfc822