A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Event for folders changing



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old April 14th 07, 04:42 AM posted to microsoft.public.outlook.program_vba
David
external usenet poster
 
Posts: 196
Default Event for folders changing

I have googled around a bit and haven't found what I need.
I am coding in C#, not VB.

Outlook 2002 and above.
I have some New Mail, Reply buttons. I only want to enable these at the
same time Outlook enables the proper ones.

So if they change folders to Today or Calendar, I would like to remove the
buttons I have added.

I can't figure out which event I should be registering for?
And, assuming an event, which property should I check to determine if:
1. I am viewing mail items
2. One is selected (otherwise I want to disable Reply)
3. If the Calendar has been selected
4. If Notes are active, since I will also want to do something similar with
Notes.

Looking for some examples, so if you are aware of any code snippets (VB if
C# note available) that do this kind of thing, point them out to me.

Much appreciated.
Dave

Ads
  #2  
Old April 14th 07, 06:37 PM posted to microsoft.public.outlook.program_vba
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default Event for folders changing

This is for an Explorer window (folder view) only?

Use ActiveExplorer.CurrentFolder to determine what folder is being displayed
and what type it is.

Outlook.MAPIFolder folder = (Outlook.MAPIFolder)
appOL.ActiveExplorer().CurrentFolder;

if(folder.DefaultItemType == OlItemType.olMailItem)
{
// it's a mail folder

// for a calendar folder
// if folder.DefaultItemType == OlItemType.olAppointmentItem
}

int itemsSelected = folder.Selection.Count;

Don't try to do much with Notes, they're brain dead. Never, ever try to add
a UI to an open Note Inspector.

The event to register for is Explorer.CommandBars.OnUpdate(). The
ActiveExplorer() is the one you want to use. However, that's an expensive
event to handle, it fires all the time. It also fires multiple times for
just one change and when buttons are being disabled you can expect it to
fire many times.

That event passes no in arguments so you will have to monitor certain
CommandBarButton objects to check their Enabled state. The CommandBar
objects are in the Office tlb.

You also have to be aware that there is no deterministic way to know when
your handler for the event will fire relative to when the buttons such as
Reply are disabled. You will have to test for that and possibly handle a few
test cases.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm


"David" wrote in message
news
I have googled around a bit and haven't found what I need.
I am coding in C#, not VB.

Outlook 2002 and above.
I have some New Mail, Reply buttons. I only want to enable these at the
same time Outlook enables the proper ones.

So if they change folders to Today or Calendar, I would like to remove the
buttons I have added.

I can't figure out which event I should be registering for?
And, assuming an event, which property should I check to determine if:
1. I am viewing mail items
2. One is selected (otherwise I want to disable Reply)
3. If the Calendar has been selected
4. If Notes are active, since I will also want to do something similar
with
Notes.

Looking for some examples, so if you are aware of any code snippets (VB if
C# note available) that do this kind of thing, point them out to me.

Much appreciated.
Dave


 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Changing RTF Body on MailItem Read event [email protected] Add-ins for Outlook 3 September 13th 06 07:30 PM
Changing a Column in Multiple Folders Simultaneously JerryZ Outlook - Installation 1 August 11th 06 08:27 PM
changing reoccuring event timezones.. Adam Outlook - Calandaring 0 August 11th 06 07:45 AM
Changing View For Public Folders [email protected] Outlook - General Queries 1 August 11th 06 04:09 AM
changing column views in folders MG Outlook Express 1 April 24th 06 03:26 PM


All times are GMT +1. The time now is 07:12 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.