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)
{
}
}
}
<kenslovak@mvps.org> wrote in message
news:%23TeQsEXsKHA.3656@TK2MSFTNGP06.phx.gbl...
> I'm not sure where you're changing the search folder refresh rate, but
> there's no such method in the Outlook object model. In fact, using the OOM
> there isn't much you can do other than delete the existing search folder
> and create a new one on each Outlook startup. Other than setting a search
> folder using the Search object and saving the search to create a search
> folder there isn't much to work with for you. You can get the existing
> search folder, delete it and create a new one.
> The Redemption (www.dimastr.com/redemption) object model has an
> RDOSearchFolder object where you can call Stop() and Start() methods that
> effectively force a refresh, but not in the Outlook object model.
> >
>
> "Mark B" <none123@none.com> wrote in message
> news:%23dApWgSsKHA.3656@TK2MSFTNGP06.phx.gbl...
> > VSTO, C#, OL2007
>
>> I need to refresh a search folder on Outlook Open since the DASL criteria
> > has a %Today function which works OK on the day the item first appears in
> > the folder but doesn't work the following day when I open up Outlook.
>
>> I have just changed the folder's refresh rate to 5 minutes but this still
> > means the user may get the wrong results when they first open Outlook in
> > the morning -- unless they presumably wait 5 minutes.
>
>> I saw that the folder object has a Refresh rate property but could find a
> > Refresh method to call.
>