Microsoft Graph API)Is any option create message from a MIME, NOT as Draft?
I am Using Microsoft Graph REST API 1.0, trying to create a new message (not draft) from a MIME but I came into some issues.
I managed to create a message using a base64 encoded MIME but it gets flagged as a draft (isDraft=true) (https://learn.microsoft.com/en-us/graph/api/user-post-messages?view=graph-rest-1.0&tabs=http)
According to multiple sources isDraft flag can only be set at message creation so I take the previously created message, change isDraft flag to false using a SingleValueLegacyExtendedProperty and I POST it to the inbox but the original MIME headers get modified (a lot of the original removed, some new created) and I need to keep them like the original.
Why MIME original headers are modified after change isDraft and respost the same message? Is there a way to avoid this behavior?
Also if there is another aproach to archive what I want, please let me know.
Thanks!
Some of my code below
// 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);