Microsoft.Exchange.WebServices.Data.EmailMessage error "The operation can't be performed because the item is out of date. Reload the item and try again"

David Joyce 150 Reputation points
2024-05-23T08:49:37.1566667+00:00

Hi,

I have been using Microsoft Exchange Web Services for a couple of years in my asp.net c# system and had no issues.

Last week 1 customer started getting below error, then yesterday another customer and 2 more today!

Microsoft.Exchange.WebServices.Data.EmailMessage error "The operation can't be performed because the item is out of date. Reload the item and try again"

Could you please advise why this may happen and what possible ways are to resolve this?

Regards & Thanks,

David

Exchange Server Development
Exchange Server Development
Exchange Server: A family of Microsoft client/server messaging and collaboration software.Development: The process of researching, productizing, and refining new or existing technologies.
525 questions
{count} votes

Accepted answer
  1. Philippe Van Cauwenbergh 85 Reputation points
    2024-05-24T10:03:17.2533333+00:00

    I have a work around.

    I noticed that when the error occured, the mail was in the drafts folder, but got stuck there.

    Work around;

    Step 1 : instead of message.send() or message.sendandsave() , use message.Save(WellKnownFolderName.Drafts);

    Step 2 : read the drafts folder (you can make a filter list of the mails in the drafts folder) and sendandsave() the drafts mail.

            try
    
            {
    
                var cca = ConfidentialClientApplicationBuilder
    
                                            .Create(L_FactuurmailAppid)
    
                                            .WithClientSecret(L_FactuurmailClientSecret)
    
                                            .WithTenantId(L_FactuurmailTenant)
    
                                            .Build();
    
                var ewsScopes = new string[] { "https://outlook.office365.com/.default" };
    
                var authResult = cca.AcquireTokenForClient(ewsScopes).ExecuteAsync().GetAwaiter().GetResult();
    
                ExchangeService exchange = new ExchangeService(ExchangeVersion.Exchange2013_SP1);
    
                exchange.Timeout = 100000000;
    
                exchange.Url = new Uri("https://outlook.office365.com/EWS/Exchange.asmx");
    
                exchange.Credentials = new OAuthCredentials(authResult.AccessToken);
    
                // exchange.ImpersonatedUserId = new ImpersonatedUserId(ConnectingIdType.SmtpAddress, L_FactuurmailFrom);
    
                exchange.ImpersonatedUserId = new ImpersonatedUserId(ConnectingIdType.SmtpAddress, "your_email_adres@test.com");
    
                exchange.Timeout = 1000000;
    
                exchange.KeepAlive = true;
    
                //// verstuur alle mails uit DRAFTS FOLDER
    
                // Bind to the Drafts folder
    
                FolderId draftsFolderId = new FolderId(WellKnownFolderName.Drafts);
    
                // Define a search filter for the subject containing "your_mailsubject_selection_text"
    
                SearchFilter searchFilter = new SearchFilter.ContainsSubstring(ItemSchema.Subject, "your_mailsubject_selection_text");
    
                // Define the item view to specify the number of items to retrieve
    
                ItemView view = new ItemView(100); // Adjust the number if needed
    
                // Find items in the Drafts folder matching the search filter
    
                FindItemsResults<Item> draftItems = exchange.FindItems(draftsFolderId, searchFilter, view);
    
                foreach (Item item in draftItems.Items)
    
                {
    
                    if (item is EmailMessage draftEmail)
    
                    {
    
                        // Send the email
    
                        draftEmail.SendAndSaveCopy();
    
                    }
    
                }
    
            }
    
            catch (Exception ex)
    
            {
    
                MessageBox.Show("Sending from DRAFTS FOLDER failes !\n" + ex.Message.ToString());
    
            }
    ```Hope this helps
    
    Additional notice:
    
    I was too optimistic. I had to build a loop around the emails in Drafts folder untill Drafts folder is empty
    
    
    2 people found this answer helpful.

11 additional answers

Sort by: Most helpful
  1. Lukas Kindig 5 Reputation points
    2024-05-28T07:51:53.4933333+00:00

    We are having the same issues since Thursday, May 23. Some mails are sent, while others are not, with the above error-message.

    Using Microsoft.Exchange.WebServices.dll with Version 2.2.1.0!

    1 person found this answer helpful.
    0 comments No comments

  2. Thomas Haack 5 Reputation points
    2024-06-04T17:48:57.19+00:00

    Via support apparently this issue is being tracked as EX796633 but it's not appearing in Service Health for me in admin.microsoft.com. Is it appearing for anyone else?

    Here's what I received from MS support:

    • Issue ID: EX796633
    • Title: Some users can’t send email messages from mailboxes through the EWS API
    • User Impact: Users are experiencing difficulties sending email messages from mailboxes via the EWS API.
    • Current Status: Our team is diligently reviewing the information provided by support to determine the next steps in our troubleshooting process.
    • Scope of Impact: Your organization may be affected by this event, particularly if some of your users are attempting to send emails from mailboxes using the EWS API.
    • Next Update: We will provide further updates by Wednesday, May 29, 2024, at 4:30 PM UTC.
    1 person found this answer helpful.

  3. René de Jong 0 Reputation points
    2024-05-24T08:08:22.18+00:00

    Any updates about this problem?

    0 comments No comments

  4. Philippe Van Cauwenbergh 85 Reputation points
    2024-05-24T08:13:42.5633333+00:00

    Same issues in my environment. using Microsoft.Exchange.WebServices 2.2.0 and Exchange.WebServices.Managed.Api 2.2.1.1

    Any estimates on fixing the issue ?

    0 comments No comments