question

JonathanF-8544 avatar image
0 Votes"
JonathanF-8544 asked GlenScales-6756 answered

Outlook Graph API ignore header prefer timezone

We are using Outlook Graph API to archive emails from certains mailbox.

When we retreive emails by Graph API, we always get them in an UTC time zone format even with a prefer header in the request. Any idea?

This is my sample code :

const response = await client
.api(`/me/mailFolders/${folderID}/messages?$top=20${filter}`)
.header('Prefer', 'outlook.timezone="Eastern Standard Time"')
.select('id, receivedDateTime, from, subject, body, hasAttachments')
.get();

microsoft-graph-mail
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

GlenScales-6756 avatar image
0 Votes"
GlenScales-6756 answered

The timezone header only affects the Events endpoint, with email the constant is that Exchange always stores datetime in UTC so its up to the client to convert that into whatever timezone is needed. The reason you need that header in the Events endpoint is that Calendar Events are created with a specific timezone (or the Organizer) so to ensure that the event Start and End times gets converted to the correct time based on the Organizer timezone offset that header is needed (as its a little too complex for the client to do that).

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.