Is there a RefreshNow action for Search Folder?

Status
Not open for further replies.
M

Mark B

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.
 
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.
 
Yes I see now. The Refresh rate method was created by another programmer

here. It simply deleted the folder and recreated it again.
<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.

>
 
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.

>
 
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" <none123@none.com> wrote in message

news:Oxk5MCasKHA.4704@TK2MSFTNGP04.phx.gbl...
> 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)
> {
> }
> }
> }
>
 
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.
<kenslovak@mvps.org> wrote in message

news:OlAKYmbsKHA.4220@TK2MSFTNGP05.phx.gbl...
> 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" <none123@none.com> wrote in message
> news:Oxk5MCasKHA.4704@TK2MSFTNGP04.phx.gbl...
> > 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)
> > {
> > }
> > }
> > }
> >

>
 
The cause of the message is pretty obvious from the message itself, no?

"Mark B" <none123@none.com> wrote in message

news:%23v$7DK6sKHA.5356@TK2MSFTNGP02.phx.gbl...
> 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.
 
I would think not because if the folder was deleted why would it still

appear in the list of folders (albeit italicized)? The message appears to

the right where list of search results normally appears.
<kenslovak@mvps.org> wrote in message

news:uCMfid8sKHA.4636@TK2MSFTNGP06.phx.gbl...
> The cause of the message is pretty obvious from the message itself, no?

> >

>

> "Mark B" <none123@none.com> wrote in message
> news:%23v$7DK6sKHA.5356@TK2MSFTNGP02.phx.gbl...
> > 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.

>
 
Was it actually deleted? Did you get the long-term EntryID (from MAPI) or

the EntryID from Outlook and save it to get the folder again? If it was

actually deleted then the folder list was corrupted.

Start Outlook using the /resetnavpane startup switch, which will reset the

navigation pane to the default if you suspect corruption in the view.

"Mark B" <none123@none.com> wrote in message

news:OowRMENtKHA.5612@TK2MSFTNGP05.phx.gbl...
> I would think not because if the folder was deleted why would it still
> appear in the list of folders (albeit italicized)? The message appears to
> the right where list of search results normally appears.
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
N "Perform a Custom Action" Outlook VBA and Custom Forms 0
S Command Button_Click action on Item/Reminder Outlook VBA and Custom Forms 3
F "This action is not available in the current mode" Using Outlook 0
Bri the Tech Guy Registry Tweak to make "Run a Script" Action Available Outlook VBA and Custom Forms 2
J Forward Action in Form Outlook VBA and Custom Forms 1
E you don't have permission to perform this action exchange 2016 Exchange Server Administration 0
I There is no email program associated to perform requested action Using Outlook 0
B Action Plans or Activity Sets in Outlook? Using Outlook 8
S Using "start application" rule action Using Outlook 2
R The action cannot be completed. The connection to Microsoft Exchange is unavailable. outlook must be Using Outlook 1
R send/receive no action Using Outlook 2
G Rule: IF mail received by X, THEN no action; IF mail not received by X, SEND Using Outlook 0
O Where is Launcher, the custom action for Exchange server? Exchange Server Administration 1
M send/ receive action too often Using Outlook 2
B Reply to All custom action doesn't work with attachments in Outlook 2007 Using Outlook 1
T getting an error This file does not have a program associated with it for performing this action. C Using Outlook 7
R could not complete your last action or actions BCM (Business Contact Manager) 2
D Running a Program from Custom Action Rule Outlook VBA and Custom Forms 1
L How to develop a custom action which can used in Rules Wizard? Outlook VBA and Custom Forms 2
A Error Message: The subject is not trusted for the specified action Outlook VBA and Custom Forms 3
B Upgrade to 2007, Action stopped working Outlook VBA and Custom Forms 3
D How can I make an action automatically make an appointment? Outlook VBA and Custom Forms 3
T Err - BCMgr contacts - Could not compl last action - try agin BCM (Business Contact Manager) 2
Q How do I create a custom action for a rule? (Save as "Nfy.MSG") Outlook VBA and Custom Forms 1
M Search message, then (1) Jump to folder & (2) Select message that you searched for Outlook VBA and Custom Forms 2
G Search Folders and Jump to Folder Outlook VBA and Custom Forms 2
A 'search people' now asks me to 'press enter' Using Outlook 8
A Relocate Search Bar in Outlook Using Outlook 2
A Search folder and move the email Outlook VBA and Custom Forms 0
farrissf Outlook 2016 Optimizing Email Searches in Outlook 2016: Seeking Insights on Quick Search vs Advanced Search Features Using Outlook 0
C Advanced search terms for "Outlook Data File" Using Outlook 1
T How to find or display the sub-folder name for an Archive Search Using Outlook 10
P Search folder: all emails sent to or from a domain Using Outlook 1
T Outlook365 search item listed as "potential matches" can't be opened Using Outlook 0
Victor_50 Outlook 2019 Jump to folder from search folder Outlook VBA and Custom Forms 0
E Outlook 365 Save Selected Email Message as .msg File - oMail.Delete not working when SEARCH Outlook VBA and Custom Forms 0
Witzker Outlook 2019 Macro GoTo user defined search folder Outlook VBA and Custom Forms 6
J Outlook search bar in Office 2021 Professional Using Outlook 1
T Outlook 365 Search Box reverting to old location Using Outlook 2
P Outlook 2013 search no longer works Using Outlook 2
C How to search for items in Outbox with multiple accounts? Using Outlook 20
J search doesn't find anything Using Outlook 1
kkqq1122 How would I add Search for attachment name Outlook VBA and Custom Forms 3
A Any way to force sort by/group by on search results with VBA? Outlook VBA and Custom Forms 1
B Search and Find Email by Folder Name Outlook VBA and Custom Forms 2
C Search not accurate, but not indexing Using Outlook 9
J How do you disable address search box when typing @ in body of email? Using Outlook 0
H Outlook 2019 intermittent search results Using Outlook 0
D Create advanced search (email) via VBA with LONG QUERY (>1024 char) Outlook VBA and Custom Forms 2
D Advanced e-Mail search on from/to contact group only searches for first 20 contacts in group Using Outlook 0

Similar threads

Back
Top