How to restore deleted mail from office 365 using Microsoft graph api

前端 未结 1 2034
再見小時候
再見小時候 2021-01-21 23:01

I want to restore a mail which we delete using Microsoft graph api.

I don\'t find any api to restore or recoved a deleted mail using apis.

相关标签:
1条回答
  • 2021-01-21 23:17

    There is no restore method in the Graph API (there also isn't one in MAPI or EWS). When an Item gets deleted in Exchange it just gets moved into another folder in the Mailbox up until the time the retention period of the Item expires then the MFA(Managed Folder Assistant) deletes the Items.

    So for example to restore an Item that was in the dumpster you would need to query for the Item in the dumpster like

     https://graph.microsoft.com/v1.0/users('user@mailbox.com')/MailFolders/recoverableitemsDeletions/messages/
    

    Then you could move it back into what ever folder you want using https://docs.microsoft.com/en-us/graph/api/message-move?view=graph-rest-1.0&tabs=http

    If you wanted to move it back to the original location it was deleted from you would need to use the LAPFID (Last Active Parent FolderId) property https://blogs.technet.microsoft.com/exchange/2017/06/13/announcing-original-folder-item-recovery/ . Eg to get that on items in the dumpster use

    https://graph.microsoft.com/v1.0/users('user@mailbox.com')/MailFolders/recoverableitemsDeletions/messages/?$select=Subject&$Top=10&$expand=SingleValueExtendedProperties($filter%3DId%20eq%20'Binary%200x348A')
    

    Using the LAPFID is a little tricky as it's only a partial folderId so you need extra code for that, there are a few examples of using it in https://gsexdev.blogspot.com/2018/10/using-lapfid-last-active-parent.html

    0 讨论(0)
提交回复
热议问题