I want to get messages from archive mailbox (enabled In-Place Archive) using Graph API. Could you, please, answere me: how I can do it?
I found similar questions but last answer was 1 year ago. Links to questions:
I want to get messages from archive mailbox (enabled In-Place Archive) using Graph API. Could you, please, answere me: how I can do it?
I found similar questions but last answer was 1 year ago. Links to questions:
You can use a "well-known" folder name
ArchiveMsgFolderRoot
to access the archive mailbox. For example, to get all messages from the Inbox folder inside the archived mailbox use the following query:
GET https://graph.microsoft.com/v1.0/users/<id>/mailFolders/ArchiveMsgFolderRoot/childFolders/Inbox/messages
btw, it uses another predefined folder id (Inbox
)
A bit more details on how to work with Archived Mailbox via Graph API
First, get the mailFolder list for your account.
GET https://graph.microsoft.com/v1.0/me/mailFolders/
Response:
{
"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#users(' ')/mailFolders(id,displayName)",
"@odata.nextLink": "https://graph.microsoft.com/v1.0/me/mailFolders?$select=id%2cdisplayName&$skip=10",
"value": [
...
{
"id": "AAMkADQ5OWMzMGEwLTg4ZjktNDk1Ny05NzFmLsdfZjg4ODU0YzUwYwAuAAAAAACtqDzk9UzLSpZsdesjndr1AQBNzq1HG8BvRYqBQbPeZSPaAAGdwZCCAAA=",
"displayName": "archive"
}
...
]
}
Then, use the archive mailboxs's id(AAMkADQ5OWMzMGEwLTg4ZjktNDk1Ny05NzFmLsdfZjg4ODU0YzUwYwAuAAAAAACtqDzk9UzLSpZsdesjndr1AQBNzq1HG8BvRYqBQbPeZSPaAAGdwZCCAAA= on my test case) to get the messages in root folder and sub-folder. Combine them on you client.
GET https://graph.microsoft.com/v1.0/me/mailFolders/{archive mailbox id}/childFolders/messages
GET https://graph.microsoft.com/v1.0/me/mailFolders/{ archive mailbox id}/messages