【发布时间】:2018-10-10 19:30:04
【问题描述】:
我正在使用ews-java-api 创建一个新的电子邮件消息,其中包含现有项目作为附件。我按照 Glen 对this 问题的回答在 java 中编写了类似的代码。但是,我收到错误消息 - “不支持将 EmailMessage 类型的项目作为附件”
这是我的代码 sn-p 供参考:
EmailMessage approvalMessage = new EmailMessage(exchangeService);
ItemAttachment itemAttachment = approvalMessage.getAttachments().addItemAttachment(EmailMessage.class);
MimeContent mimeContent = ewsItem.getMimeContent();
Item attachedItem = itemAttachment.getItem();
attachedItem.setMimeContent(mimeContent);
ExtendedPropertyDefinition prFlags = new ExtendedPropertyDefinition(3591, MapiPropertyType.Integer);
attachedItem.setExtendedProperty(prFlags, "1");
itemAttachment.setName(subject);
approvalMessage.setSubject("Reminder Email with original email as attachment");
approvalMessage.getToRecipients().add("my-email-address");
approvalMessage.send();
- approvalMessage 是我正在创建的新电子邮件
- ewsItem 是我想作为附件添加到approvalMessage 的现有项目
问题:这是 ews-java-api 不接受 EmailMessage 作为附件类型的问题吗?
我尝试了什么:我用ItemAttachment itemAttachment = approvalMessage.getAttachments().addItemAttachment(Item.class);替换了ItemAttachment itemAttachment = approvalMessage.getAttachments().addItemAttachment(EmailMessage.class);
发布此更改,我不再观察到上述错误。但是,代码现在会在以下行引发 stackoverflow 错误 - attachedItem.setMimeContent(mimeContent);
错误堆栈跟踪-
Oct 09, 2018 9:02:45 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet [dispatcher] in context with path []
threw exception [Handler dispatch failed; nested exception is
java.lang.StackOverflowError] with root cause
java.lang.StackOverflowError
at microsoft.exchange.webservices.data.core.PropertyBag.changed
(PropertyBag.java:364)
at microsoft.exchange.webservices.data.property.complex.ItemAttachment.
itemChanged(ItemAttachment.java:96)
at microsoft.exchange.webservices.data.property.complex.ItemAttachment.
serviceObjectChanged(ItemAttachment.java:252)
at microsoft.exchange.webservices.data.core.service.ServiceObject.
changed(ServiceObject.java:85)
at microsoft.exchange.webservices.data.core.PropertyBag.changed
(PropertyBag.java:364)
at microsoft.exchange.webservices.data.property.complex.ItemAttachment.
itemChanged(ItemAttachment.java:96)
at microsoft.exchange.webservices.data.property.complex.ItemAttachment.
serviceObjectChanged(ItemAttachment.java:252)
at microsoft.exchange.webservices.data.core.service.ServiceObject.
changed(ServiceObject.java:85)
问题:为什么将Item指定为附件类会导致stackoverflow错误?将现有项目添加为附件的正确方法是什么?
【问题讨论】:
标签: exchange-server exchangewebservices