Skip to content

MailItem Message ID Changes After Sending — Causes ‘Item Not Found’ on Lookup #2947

@shivani-cloudextend

Description

@shivani-cloudextend

Describe the bug

We are using Microsoft Graph to create and send emails in the following way:

  1. Create a draft message
    var draftMessage = await graphClient.Users[userEmail].Messages.PostAsync(message);
  2. Send the draft message
    await graphClient.Users[userEmail].Messages[draftMessage.Id].Send.PostAsync();
  3. Get the sent message using its internetMessageId
    After sending, we try to retrieve the sent message by filtering with its internetMessageId:
var filter = $"internetMessageId eq '{draftMessage.InternetMessageId}'";

var messageCollectionResponse = await graphClient.Users[userEmail].Messages.GetAsync(
    requestConfiguration => requestConfiguration.QueryParameters.Filter = filter
);

The issue is
When we create the draft, we receive an initial message.Id.

After sending the message, we can look it up successfully using the internetMessageId.
However, after some time, the original messageId becomes invalid — it changes in the mailbox, and trying to retrieve the message by the old ID results in an ErrorItemNotFound error.

Expected behavior

The messageId returned when creating or sending the message should remain consistent and valid

How to reproduce

.

SDK Version

5.16.0

Latest version known to work for scenario above?

No response

Known Workarounds

No response

Debug output

Click to expand log ```
</details>


### Configuration

_No response_

### Other information

_No response_

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions