Move email not working in logic app

Abhishake Jaiswal 160 Reputation points
2023-07-21T00:37:22.75+00:00

My logic app polls a shared mailbox for new emails, mark emails as read and move the emails to Archive folder of shared mailbox. but i am getting error message at marking email as read.

	 "error": {
            "code": "ErrorInvalidMailboxItemId",
            "message": "Item 'AAMkADdkYmJkNDI2LWMwNDAtNGNiZi1iNGJjLWQ5MDB****************************************************************KAAAAAAEMAACq1ydr3P_KRJlHr_4G2NgKAABh9RZcAAA=' doesn't belong to the targeted mailbox '<<MailboxID>>
            "innerError": {
                "date": "2023-07-21T00:21:44",
                "request-id": "<<some unique ID>>",
                "client-request-id": "<<some unique ID>>"
            }

I tried by directly moving the email to Archive folder but again i am getting error message :

"status": 404,
        "message": "Item 'AQMkADRmNTE3NGJmLTEwY2EtNDk4YS1hYzlmLWM0OGE4OABiNDg3OGIALg***************************************' doesn't belong to the targeted mailbox '<<MailboxID>>'.\r\nclientRequestId: <<someuniqueID>>\r\nserviceRequestId: <<someuniqueID>>"

Is there any limitation in doing this ? Any help would be appreciated.

User's image



Azure Logic Apps
Azure Logic Apps
An Azure service that automates the access and use of data across clouds without writing code.
3,087 questions
0 comments No comments
{count} votes

Accepted answer
  1. Saurabh Sharma 23,801 Reputation points Microsoft Employee
    2023-07-21T20:59:38.78+00:00

    @Abhishake Jaiswal

    Thanks for using Microsoft Q&A !!

    The error you are seeing is because of the change mentioned in devblogs notification according to which

    accessing delegator's mailbox items using api/v2.0/me/messages/{message-id} is no longer supported. Please find below the notification snippet -

    User's image

    Additionally, it was recommended to use Microsoft Graph API Mail endpoints to access Outlook items in an archive mailbox, or items belonging to another user in a delegated or shared mailbox.

    Please find below steps which you can follow to Mark the Email as Read and then Move the message to Archive Folder -

    1. Create an HTTP with Azure AD Connection by using the Base url as https://graph.microsoft.com

    User's image

    1. Once you click on Sign In, you will be asked to provide credentials to connect and after successful connection you should be able to use the Microsoft Graph REST API endpoints.
    2. Please use the Microsoft Graph Endpoint to Update Message as Read Only-

    https://graph.microsoft.com/v1.0/users/sharedmailbox@test.onmicrosoft.com/messages/{MessageId}

    In this call you need to do PATCH by passing the IsRead to true in Request Body as below.

    {
      "isRead": "true"
    }
    

    Please refer to Request body section to know the properties which can be updated through the endpoint.

    So, your logic app step will look like below -

    User's image

    1. Then you can use the Move endpoint to move the previously read email to archive folder

    https://graph.microsoft.com/v1.0/users/sharedmailbox@test.onmicrosoft.com/messages/{messageid}/move

    In this call you need to do a POST by passing the Destination folder name in Request Body as below.

    {
    "destinationId": "archive"
    }
    

    Please refer to this page to know the folder names which you can use.

    Logic app step will look like below -

    User's image

    Please find below screenshot with all the steps-

    User's image

    I have tested this and it works as expected. Please let me know if you have any other questions.

    Thanks

    Saurabh


    Please do not forget to "Accept the answer" wherever the information provided helps you to help others in the community.


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.