locked
The message filter indicated that the application is busy. (Exception from HRESULT: 0x8001010A (RPC_E_SERVERCALL_RETRYLATER)) RRS feed

  • Question

  • Hello all,

    I am trying to extract a MSG files from a PST. While extracting, I randomly get the following error:

    The message filter indicated that the application is busy. (Exception from HRESULT: 0x8001010A (RPC_E_SERVERCALL_RETRYLATER))

    Any suggestions how to remove this error. I can post the code in case that helps.

    Friday, April 3, 2015 3:06 PM

Answers

  • Do you mean you would get that error when calling "new Application"?

    It means what it says - the app you are calling (Outlook) is busy and the COM system timed out waiting for it. You need to retry later.


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.5 is now available!

    Friday, April 3, 2015 3:54 PM

All replies

  • Which call returns that error?


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.5 is now available!

    Friday, April 3, 2015 3:13 PM
  • Hi Dmitry,

    below is the sample code for the application. Usually i get this error randomly Application, Namespace or other Com objects. However, most of the times I get it right at Application.


    private static void fnExtractMSGFiles(string strPSTFileName, string pstFilePath)
            {
                Application app = new Application();
                NameSpace outlookNs = null;
                MAPIFolder rootFolder = null;
                Folders subFolders = null;
                Items items = null;


                try
                {
                    outlookNs = app.GetNamespace("MAPI");

                    // Add PST file (Outlook Data File) to Default Profile
                    outlookNs.AddStore(pstFilePath);
                    rootFolder = outlookNs.Stores[2].GetRootFolder();
                    string strStoreName = outlookNs.Stores[2].DisplayName.ToString();

                    // Traverse through all folders in the PST file
                    subFolders = rootFolder.Folders;

                    foreach (Folder folder in subFolders)
                    {
                        string stringFolderPath = strExtractedFolderPath + strPSTFileName + @"\" + strStoreName + @"\" + folder.Name.ToString();
                        items = folder.Items;

                        foreach (object item in items)
                        {
                            if (item is MailItem)
                            {
                                if (!Directory.Exists(stringFolderPath))
                                    Directory.CreateDirectory(stringFolderPath);

                                // Retrieve the Object into MailItem
                                MailItem mailItem = item as MailItem;

                               
                                if (mailItem.Subject != null)
                                {
                                    // Save the message to disk in MSG format without invalid characters [\ / : * ? " < > |]
                                    string filePath = stringFolderPath + @"\" + Regex.Replace(mailItem.Subject, @"[^\w\.@-]", "", RegexOptions.None, TimeSpan.FromSeconds(1.5));
                                    if (filePath.Length > 150)
                                        filePath = filePath.Substring(0, 150) + ".msg";

                                    else
                                        filePath = filePath + ".msg";

                                    if (File.Exists(filePath))
                                    { 
                                     // If duplicate file exists then create a copy of it
                                    }
                                    else
                                        mailItem.SaveAs(filePath, OlSaveAsType.olMSG);

                                    Console.WriteLine("Folder :- " + folder.Name + "--------" + "MailItem Name :- " + mailItem.Subject);

                                }

                                if (mailItem != null)
                                    Marshal.FinalReleaseComObject(mailItem);

                                
                            }
                        }
                    }

                    Thread.Sleep(1000);

                    // Remove PST file from Default Profile
                    outlookNs.RemoveStore(rootFolder);                

                    // Copy PST files to backup folder
                    fnCopyExtractedPSTFiles(pstFilePath, strPSTFileName);
                    

                }

                catch (System.Exception ex)
                {
                    //Log exception here

                    // Remove PST file from Default Profile
                    outlookNs.RemoveStore(rootFolder);
                }

                finally 
                {
                    //Release com objects
                    if (items != null)
                        Marshal.ReleaseComObject(items);

                    if (subFolders != null)
                        Marshal.ReleaseComObject(subFolders);

                    if (rootFolder != null)
                        Marshal.ReleaseComObject(rootFolder);

                    if (outlookNs != null)
                        Marshal.ReleaseComObject(outlookNs);

                    if (app != null)
                        Marshal.ReleaseComObject(app);

                    Thread.Sleep(1000);

                }

            }


    ashishshukla.1183

    Friday, April 3, 2015 3:31 PM
  • Do you mean you would get that error when calling "new Application"?

    It means what it says - the app you are calling (Outlook) is busy and the COM system timed out waiting for it. You need to retry later.


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.5 is now available!

    Friday, April 3, 2015 3:54 PM
  • Hi Dmitry,

    You are right. Thats when I get mostly the error.

    I understand the application is busy to retrieve any data, but what should be done to avoid such error.

    In my case, I donot have outlook (infact any office application) opened in the background. So I guess, my code only is instantiating outlook process. So not sure how to handle such scenarios.

    I have even induced a sleep time of 3000, but that even didn't helped.


    ashishshukla.1183

    Friday, April 3, 2015 4:01 PM
  • Try something like the following:

    uint errorCode = 0;
    do
    {
      try
      {
        Application app = new Application();
      }
      catch(COMException ce)
      {
        errorCode = (uint)ce.ErrorCode; 
      }
    } while (erroCode == 0x8001010A);
    


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.5 is now available!

    Friday, April 3, 2015 4:07 PM
  • Hi Dmitry,

    I induced sleep time just after new application and it works fine so far. I guess that object is was causing the trouble.


    ashishshukla.1183

    Friday, April 3, 2015 4:25 PM