Closed zxyty closed 1 year ago
Which Platform[PC desktop, Mac, iOS, Office on the web] do you see this issue? Could you also provide us the details about the language you are using for Outlook?
The PC desktop I use, and in the Chinese region, the Outlook client is Chinese language.
dateTimeCreated is returning the MAPI Property PR_CREATION_TIME. The Outlook UI displays PR_CLIENT_SUBMIT_TIME.
Hence the difference.
PR_CLIENT_SUBMIT_TIME is not available via Office.Js. If this is needed, it may be able to get the property via EWS makeEwsRequestAsync and GetItem (or through REST or Graph).
https://docs.microsoft.com/en-us/office/client-developer/outlook/mapi/pidtagclientsubmittime-canonical-property https://docs.microsoft.com/en-us/exchange/client-developer/web-service-reference/getitem-operation https://docs.microsoft.com/en-us/exchange/client-developer/web-service-reference/additionalproperties https://docs.microsoft.com/en-us/exchange/client-developer/web-service-reference/extendedfielduri
This issue has been automatically marked as stale because it is marked as needing author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment. Thank you for your interest in Office Add-ins!
Please help to check
There isn't more to check? Unless you have another question? The Office.js API IS returning to you the PR_CREATION_TIME. If you want another property (such as PR_CLIENT_SUBMIT_TIME) that is not available via the API at this time. You can fetch it via EWS or Graph/REST.
Because both EWS and Graph apis are exclusive to certain email accounts, we are unable to utilize them to accomplish this due to the constraints of our business situation; Furthermore, our plugin is designed to work with various users and accounts.
Other Case: When i use the Office.context.mailbox.item object, I need to get the original message reception date. But I only have dateTimeCreated and dateTimeModified. But Current behavior is when I get the Office.context.mailbox.item object, it returns the dateTimeCreated and dateTimeModified date set to today, so I cannot know when the mail was received. There are any way to get the original received date?
This property is not available in Office.js API. Feature suggestions can be made at: https://aka.ms/M365dev-suggestions
However, it is unlikely that a change will be made here.
All accounts that support Web Add-ins, support EWS. If you do not want to do this server side, you use the makeEwsRequestAsync function, which is available as long as the add-in has ReadWriteMailbox permissions.
For example, the following code will retrieve both dateTimeSent and dateTimeReceived:
var ewsId = Office.context.mailbox.item.itemId;
var request = '<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">' +
' <soap:Header><t:RequestServerVersion Version="Exchange2013" /></soap:Header>' +
' <soap:Body>' +
' <m:GetItem>' +
' <m:ItemShape>' +
' <t:BaseShape>Default</t:BaseShape>' +
'<AdditionalProperties>' +
'<FieldURI FieldURI="item:DateTimeSent" />' +
'<FieldURI FieldURI="item:DateTimeReceived" />' +
'</AdditionalProperties>' +
' </m:ItemShape >' +
' <m:ItemIds>' +
' <t:ItemId Id="' + ewsId + '" />' +
' </m:ItemIds>' +
' </m:GetItem>' +
' </soap:Body>' +
'</soap:Envelope>';
Office.context.mailbox.makeEwsRequestAsync(request, function (asyncResult) {
if (asyncResult.status == "failed") {
console.log("Action failed with error: " + asyncResult.error.message);
}
else {
console.log(asyncResult.value);
}
});
This issue has been automatically marked as stale because it is marked as needing author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment. Thank you for your interest in Office Add-ins!
This issue has been closed due to inactivity. Please comment if you still need assistance and we'll re-open the issue.
This property is not available in Office.js API. Feature suggestions can be made at: https://aka.ms/M365dev-suggestions
However, it is unlikely that a change will be made here.
All accounts that support Web Add-ins, support EWS. If you do not want to do this server side, you use the makeEwsRequestAsync function, which is available as long as the add-in has ReadWriteMailbox permissions.
For example, the following code will retrieve both dateTimeSent and dateTimeReceived:
var ewsId = Office.context.mailbox.item.itemId; var request = '<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">' + ' <soap:Header><t:RequestServerVersion Version="Exchange2013" /></soap:Header>' + ' <soap:Body>' + ' <m:GetItem>' + ' <m:ItemShape>' + ' <t:BaseShape>Default</t:BaseShape>' + '<AdditionalProperties>' + '<FieldURI FieldURI="item:DateTimeSent" />' + '<FieldURI FieldURI="item:DateTimeReceived" />' + '</AdditionalProperties>' + ' </m:ItemShape >' + ' <m:ItemIds>' + ' <t:ItemId Id="' + ewsId + '" />' + ' </m:ItemIds>' + ' </m:GetItem>' + ' </soap:Body>' + '</soap:Envelope>'; Office.context.mailbox.makeEwsRequestAsync(request, function (asyncResult) { if (asyncResult.status == "failed") { console.log("Action failed with error: " + asyncResult.error.message); } else { console.log(asyncResult.value); } });
Thanks. it's helpful!
Background:
We hope to develop a outlook add-ons by office.js, then user can use and open our add-on, then it can retrieve the current selected email's subject/from/to/cc/mailbody and the reception date displayed in user's outlook, then pass this mail and other info inputted on the add-on panel to back-end server, back-end server can re-generate the mail again. the mail is a evidence in busines, so we need to keep the same 'reception date' as it is in original user's outlook.
Requirement:
I want to through an API such as "Office. Context. Mailbox. Item. DateTimeCreated", to obtain the current mail creation time. As you can see. When i call the "Office.context.mailbox.item.dateTimeCreated" api. it return the 19:03 time for me as below image:
But I see it's different in outlook email. it's 19:01 time:
Even I found that sometimes the two times differ by several months or more than a year. I don't think it should be a time zone problem.
Your Environment
Office.js version: 1.1 (https://appsforoffice.microsoft.com/lib/1.1/hosted/office.js) Outlook client version: latest.
Expected behavior
Return a same time for me.