2 回答
![?](http://img1.sycdn.imooc.com/533e4c9c0001975102200220-100-100.jpg)
TA贡献1784条经验 获得超9个赞
虽然我仍然不太明白这里发生了什么,但我确实有一个可行的解决方案。我可以更改电子邮件的内容类型的唯一方法是在路由到邮件端点之前在 Camel 消息上设置“Content-Type”标头:
.setHeader("Content-Type", constant("text/plain"))
我什至无法通过使用邮件组件上的“contentType”查询参数来更改内容类型。
![?](http://img1.sycdn.imooc.com/545868190001d52602200220-100-100.jpg)
TA贡献1890条经验 获得超9个赞
你最近怎么样,经历了类似的事情并通过以下方式解决了我希望它会有所帮助
@Handler
public void attachmentValidate(@ExchangeProperty("MAIL_ATTACHMENTS") List<Attachment> attachments,
Exchange exchange) throws Exception {
Message in = exchange.getIn();
if (attachments != null) {
for (Attachment attachment : attachments) {
FileNameMap fileNameMap = URLConnection.getFileNameMap();
String mimeType = fileNameMap.getContentTypeFor(attachment.getName()
.substring(attachment.getName().indexOf('.'), attachment.getName().length()));
if (StringUtils.isEmpty(mimeType)) {
mimeType = "application/octet-stream";
}
byte[] decoded = Base64.getDecoder().decode(attachment.getValue());
in.addAttachment(attachment.getName(), new DataHandler(new ByteArrayDataSource(decoded, mimeType)));
}
}
exchange.setProperty("MAIL_ATTACHMENTS", attachments);
}
添加回答
举报