Thanks.
After I had been using Outlook all day, opening and closing it about 5 times
during the day, all folders suddenly appeared italicized.
Then when I clicked on any of them, the following message was displayed:
"Cannot display the folder. Microsoft Office Outlook cannot access the
specified folder location. The operation cannot be performed because the
object has been deleted."
My startup code does delete all folders and recreates them but generally
there have been no issues. Do you know what might be causing the message?
Note after I just restarted Outlook now, the folders were non-italicized and
displayed the correct results. I wouldn't want a user to have to do that
everyday though.
Ken Slovak - said:
Italicized/dimmed means the search folder hasn't been accessed in xx days
and has gone inactive. Touching it will force a rescan, as when you click
in it. Bolded with a number in square brackets indicates the number of
unread items.
This is all basic search folder UI, nothing special and nothing due to
code.
Mark B said:
Now I recreate the folders on Startup.
I have noticed some weird behavior though. Sometimes the folder titles
appear italicized and the folder icon dimmed. Then when I click on one
the titles appear normal again and I can see the search results in the
particular folder. The issue though is that the folder title no longer
has the number of items in the title, e.g. "My Search [23]". It appears
as "My Search". I set this property after I create the folder:
public void ReCreateAll()
{
foreach (SearchFolder f in sFolders.Values)
f.Create();
}
public void Create()
{
try
{
Outlook.Application olApp;
Outlook.Search search;
//Deleting existing search-folder
Remove();
//Initialization
olApp = Globals.ThisAddIn.Application;
search = olApp.AdvancedSearch(this.scopeStr, this.filter,
true, this.tag);
Outlook.MAPIFolder myFolder =
search.Save(this.FolderName);
this.EntryId = myFolder.EntryID;
myFolder.ShowItemCount =
Microsoft.Office.Interop.Outlook.OlShowItemCount.olShowTotalItemCount;
Globals.ThisAddIn.SaveSearchFoldersInfo();
}
catch (Exception e)
{
AppLogger.LogException(e);
}
}
public void Remove()
{
if (this.folderEntryId != null)
{
Outlook.Application olApp;
olApp = Globals.ThisAddIn.Application;
try
{
Outlook.MAPIFolder existingFolder =
olApp.GetNamespace("MAPI").GetFolderFromID(this.folderEntryId,
Type.Missing);
if (existingFolder != null)
existingFolder.Delete();
//Remove folder's entryID
this.folderEntryId = null;
//Save the changes
Globals.ThisAddIn.SaveSearchFoldersInfo();
}
catch (Exception)
{
}
}
}