Dynamically name command bar buttons depending on if a msg is sent?

Add-in Express™ Support Service
That's what is more important than anything else

Dynamically name command bar buttons depending on if a msg is sent?
 
Colin Fischer




Posts: 2
Joined: 2005-04-21
I have an outlook add-in with a single commandbar with a single button. The commandbar only gets displayed on email messages. I have been trying to find an event that gets fired by the add-in when it actually gets displayed so that I can update the text of the button depending on if the message has been sent or not. Is this even possible or am I just wasting my time?

Thanks

Colin Fischer
Posted 21 Apr, 2005 13:03:05 Top
Matt Driver


Guest


Hi

I have done a similar job I needed and "export" button for only sent e-mail and a "send and export" button if the e-mail is unsent. Use the Inspector_Activate object and do the following:

Firstly if you want icons on the buttons add a imagelist to your project and create two images these will be referenced as &H1 and &H2 in the code.

Next create two buttons in the control properties of the inspector one for Sent and one for unsent. Give them a caption and set the sytle to AdxMSOButtonIconAndCaption and assign these the image &H1 and &H2 above then use the following code:

Dim item as Outlook._MailItem
If Inspector.CurrentItem.Class = Outlook.OlObjectClass.oLMail Then
item = inspector.CurrentItem
If item sent then
button1.visible = true
button2.visible = false
else
button2.visible =true
button1.visible = false
end if

I found with outlook its best not to dynamically change the caption on buttons Outlook does not always refresh the text and size of the button correctly. its Microsofts issue not the add-in's. Simply making things visible and invisible works great. You can then just add code to each of the buttons events now.

Matt
Posted 22 Apr, 2005 04:01:17 Top
Matt Driver


Guest


Oh I forgot to add you can replicate this code to the Explorer if you want the same buttons when you have the e-mail not opened in its own window.

Matt
Posted 22 Apr, 2005 04:04:33 Top
Sergey Grischenko


Add-in Express team


Posts: 7233
Joined: 2004-07-05
Hi Matt.

Thank you for help.

I found with outlook its best not to dynamically change the caption on buttons Outlook does not always refresh the text and size of the button correctly

We have already fixed this issue in the latest ADX build 2.2.1750.
Posted 22 Apr, 2005 04:38:17 Top
Eugene Starostin


Guest


Hello Colin,
Hello Matt,

I think the ItemTypes property of ADX command bars and controls will help you. A small quotation from the documentation we are preparing:

To add a command bar to the Outlook Explorer/Inspector window you can use more ways:

- To add a command bar for one folder whose name is known to you, specify its name in the FolderName property and specify all item types via the ItemTypes property.

- To add a command bar for several folders whose names are known to you, specify their names in the FolderNames property and specify all item types via the ItemTypes property.

- To add a command bar for all folders, specify * (asterisk) in the FolderName property and specify all item types via the ItemTypes property.

We can combine the FolderName, FolderNames and ItemTypes properties in any way. In any case a command bar will be shown on the following condition: (FolderName or FolderNames) and ItemTypes. I.e. a command bar will be shown for a folder if its name is found in the FolderName or FolderNames properties and its item type is included into the ItemTypes property.
Posted 22 Apr, 2005 04:45:27 Top
Sergey Grischenko


Add-in Express team


Posts: 7233
Joined: 2004-07-05
Hi Colin.

I can send you an example if you wish. But could you tell me do you want to change the Caption property of the command bar when an Outlook inspector is opened or just click on an item in Outlook explorer?

Posted 22 Apr, 2005 04:47:21 Top