none
Various exceptions in Outlook 2010 Addin - Production RRS feed

  • Question

  • We have this small addin for outlook 2010. The addin in installed on around 5000 users. The addin works fine on most of the users, but some users are facing problems. We looked at the users that are facing problems and found the following exceptions thrown from the code of these users

    COM Exceptions- These are exceptions thrown at the place where we are making the calls to the Outlook API through interop. There are three such exceptions found so far.

    1. The operation failed. -The operation failed. -    at Microsoft.Office.Interop.Outlook.ApplicationClass.AdvancedSearch(String Scope, Object Filter, Object SearchSubFolders, Object Tag)
     - Code
      Log.LogMessage("SetSearchFolder start", "SetSearchFolder");


                Outlook.Folder searchFolder = null;
                try
                {
                    StringBuilder sscopebuilder = new StringBuilder();
                    //1.
                    sscopebuilder.Append("'");
                    sscopebuilder.Append(oFolder.FolderPath);
                    sscopebuilder.Append("'");

                    //2.
                    foreach (Outlook.Folder t in getChildFolders(oFolder, folderToSkip))
                    {
                        sscopebuilder.Append(",'");
                        sscopebuilder.Append(t.FolderPath);
                        sscopebuilder.Append("'");
                    }

                    Log.LogMessage("Before advanced search sscopebuilder: " + sscopebuilder.ToString() + "searchFolderName : " + searchFolderName, "SetSearchFolder");

                    //3.
                    Outlook.Search padAll = oApp.AdvancedSearch(sscopebuilder.ToString(), Type.Missing, Type.Missing, Type.Missing);
                    padAll.Save(searchFolderName);

                    //4.
                    foreach (Outlook.Folder f in oApp.Session.DefaultStore.GetSearchFolders())
                    {
                        if (f.Name.Equals(searchFolderName))
                        {
                            searchFolder = f;
                            break;
                        }
                    }
                }
                catch (Exception ex)
                {
                    LogErrorMessage(ex);
                }

                Log.LogMessage("SetSearchFolder end", "SetSearchFolder");


                return searchFolder;

    2. Not implemented (Exception from HRESULT: 0x80004001 (E_NOTIMPL)) -Not implemented (Exception from HRESULT: 0x80004001 (E_NOTIMPL)) -    at Microsoft.Office.Interop.Outlook._MailItem.get_EntryID()
     - Code
       List<MFT.EmailItem> _mailItems = new List<MFT.EmailItem>();
                try
                {
                    Outlook.MailItem mi = null;
                    for (int i = 1; _folder.Items.Count + 1 > i; i++)
                    {
                        if (_folder.Items[i] != null)
                        {
                            mi = _folder.Items[i] as Outlook.MailItem;
                            if (mi != null)
                            {
                                Log.LogMessage(" for all the items and mi is not null :  " + _folder.Name + mi.Subject , "GetEMailItems");

                                _mailItems.Add(new MFT.EmailItem(mi, _folder.Name));
                            }
                            if (mi != null && Marshal.IsComObject(mi))
                            {
                                Marshal.ReleaseComObject(mi);
                                mi = null;
                            }

                           
                        }
                    }
                }

         public EmailItem(Outlook.MailItem _mailItem,string _folderName)
            {           
                this.EntryID = _mailItem.EntryID;
                this.Attachment = false;
                Outlook.Attachments _attchs = null;
                try
                {
                    _attchs = _mailItem.Attachments;
                    if (_attchs.Count > 0)
                    {
                        this.Attachment = true;
                    }
                }
                finally
                {
                    if (_attchs != null && Marshal.IsComObject(_attchs))
                    {
                        Marshal.ReleaseComObject(_attchs);
                        _attchs = null;
                    }
                }
               
                this.From = _mailItem.SenderName;
                this.Subject = _mailItem.Subject;
                this.Date = _mailItem.SentOn;
                this.Size = _mailItem.Size;
                this.Path = _folderName;
                this.IPMType = _mailItem.Class.ToString();           
            }

    3. Not implemented (Exception from HRESULT: 0x80004001 (E_NOTIMPL)) -    at Microsoft.Office.Interop.Outlook._MailItem.get_Size()
     - I had raised another thread for this exception and i am yet to try the option suggested

    http://social.msdn.microsoft.com/Forums/en-US/outlookdev/thread/3b5671ae-2059-4ce6-ba00-41912c090093


    4.    For some of these users the toolbar is getting disabled automatically after it runs for a few days. We do not know the cause of this.


    muzammil ahmed


    • Edited by muzammil ahmed Monday, April 16, 2012 10:38 PM format change
    Monday, April 16, 2012 10:35 PM

Answers