我正在使用Microsoft Graph REST API 1.0,试图从MIME创建新消息(而不是草稿),但我遇到了一些问题。
我设法使用base64编码的MIME创建消息,但它被标记为草案(isDraft=true) (https://docs.microsoft.com/en-us/graph/api/user-post-messages?view=graph-rest-1.0&tabs=http)
根据多个来源,只能在创建邮件时设置isDraft标志,因此我采用之前创建的邮件,使用SingleValueLegacyExtendedProperty将isDraft标志更改为false,然后将其发布到收件箱
但是原始的MIME头被修改了(很多原始的被删除了,一些新创建的),我需要让它们像原始的一样。
为什么MIME原始头在更改isDraft并重新发送相同的邮件后会被修改?有没有办法避免这种行为?
另外,如果有其他方法来存档我想要的东西,请让我知道。
谢谢!
下面是我的一些代码
// Create a new message (Original MIME)
newMessage = (Message) graphServiceClient
.customRequest(String.format("/users/%s/messages/", USER_EMAIL), Message.class)
.buildRequest(new HeaderOption("Content-Type", "text/plain"))
.post(Base64.encodeBase64(IOUtils.toByteArray(
Objects.requireNonNull(
this.getClass().getClassLoader().getResourceAsStream(
MIME_MAIL_WITH_ATTACHMENTS)))));
//flag newMessage as draft (despite that newMessage has the original headers, after this update they become different from the original)
newMessage.singleValueExtendedProperties = setDraftFalse();
private SingleValueLegacyExtendedPropertyCollectionPage setDraftFalse() {
final SingleValueLegacyExtendedProperty prop = new SingleValueLegacyExtendedProperty();
prop.id = "Integer 0x0E07";
prop.value = "4";
final SingleValueLegacyExtendedPropertyCollectionResponse response = new SingleValueLegacyExtendedPropertyCollectionResponse();
response.value = new ArrayList<SingleValueLegacyExtendedProperty>();
response.value.add(prop);
return new SingleValueLegacyExtendedPropertyCollectionPage(
response, null);
}
// Post the message updated
graphServiceClient.me().messages().buildRequest().post(newMessage);
发布于 2021-11-03 22:01:26
尝试将X-Unsent: 0
添加到邮件MIME标头。
https://stackoverflow.com/questions/69831433
复制相似问题