2 回答

TA貢獻1784條經(jīng)驗 獲得超9個贊
雖然我仍然不太明白這里發(fā)生了什么,但我確實有一個可行的解決方案。我可以更改電子郵件的內(nèi)容類型的唯一方法是在路由到郵件端點之前在 Camel 消息上設(shè)置“Content-Type”標頭:
.setHeader("Content-Type", constant("text/plain"))
我什至無法通過使用郵件組件上的“contentType”查詢參數(shù)來更改內(nèi)容類型。

TA貢獻1890條經(jīng)驗 獲得超9個贊
你最近怎么樣,經(jīng)歷了類似的事情并通過以下方式解決了我希望它會有所幫助
@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);
}
添加回答
舉報