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

Ken Slovak - [MVP - Outlook]

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

Mark B

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.

>
 
M

Mark B

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.

>
 
K

Ken Slovak - [MVP - Outlook]

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)
> {
> }
> }
> }
>
 
M

Mark B

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)
> > {
> > }
> > }
> > }
> >

>
 
K

Ken Slovak - [MVP - Outlook]

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

Mark B

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.

>
 
K

Ken Slovak - [MVP - Outlook]

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
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
H Search Email Header for Content Type Outlook VBA and Custom Forms 1
P Posts in Folder No Longer Group by Conversation Column After Search Using Outlook 0
O Advanced search - can I use booleans Using Outlook 3
Y Filter unread emails in a search folder vba help Outlook VBA and Custom Forms 0
M Reverting The Outlook Search Box Location (or other undesired additions) Using Outlook 1
M Something went wrong and your search couldn't be completed Using Outlook 1
M Disable Contact Card Results when using "Search People" in Outlook Ribbon Using Outlook 7
J outlook 2007 doesn't let me choose which .pst to search Using Outlook 2
P outlook 2008 search box criteria couldn't be saved Using Outlook 2
C Outlook with Office365 - search across account, by date rate, in multiple folders - how? Using Outlook 2
D Custom Search Folders not refreshing/updating automatically Using Outlook 0
L New Location for the Search Bar Using Outlook 6
T How can you include Junk Email in Search Results like you can include Deleted Items? Using Outlook 3
J Outlook 2016 After a search in all mailboxes, where is each message that was found? Using Outlook 6
King Mustard Sort search groups by amount of items? Using Outlook 1
V Outlook 2016 will not move emails in search results Using Outlook 4
T Search for incoming e-mails for a specified time range Using Outlook 1
S outlook 2007 calendar search Using Outlook 6
M Outlook macro to automate search and forward process Outlook VBA and Custom Forms 6
J Message search and edit, another way? Outlook VBA and Custom Forms 4
S Create A Search Folder That Looks For Message Class? Outlook VBA and Custom Forms 0
R Outlook for Mac - Advanced Search and Tracking Sent Emails Using Outlook 0
R Search/Jump to a folder by typing its name Outlook VBA and Custom Forms 1
M Sent mail not showing in Sent Items folder; but they can be found with Search Using Outlook 3
A Outlook 2019 having issues with 'people search' and not making suggestions in email To: etc Using Outlook 12
W Search Incomplete Outlook 2016 Using Outlook 5
S Outlook 2007 Calendar instant search problem. Windows 7 Using Outlook 4

Similar threads

Top