Outlook VBA need to change the message icon and the menu bar icon

B

basel.sxaffolter

Hi,

I recently developed an Outlook COM addin in vba 6 which initially
creates a button (msoButtonIconAndCaption) in the standard outlook menu
bar. If the user clicks on the button, the current selected message's
will get a specific category. That works fine so far.

Now there are additional requirements.

1. If a message is marked by this specific category, the message icon
has to be changed to a custom one. I know there's a way using a Form
Setup File (.cfg) to assign a custom message class (e.g.
IPM.Note.MyMessageClassSample) and to link the icon with the CFG file.
Finally the Form Setup File can be imported either to the Exchange Org.
Lib. or into the Pers. Lib. By changing the selected message class to
the customized message class, the icon will change to the linked
Message Class defined in the Form Setup File. However, if there is a
selected message which has the forwarded/replied flag set, the message
class will change but not the icon. I know that the icon can also be
changed using CDO:

Set objCDOItem = objCDOSession.GetMessage(strEntryID, strStoreID)
objCDOItem.Fields.Add &H10800003, 511
objCDOItem.Update True

The problem I have here is that I can just use a predefined collection
of icons (PR_ICON_INDEX) and not the customized one. This method would
also allow to change the icon of a message which has the
forwarded/replied flag set, however there seems to be no way to use a
custom one. That's my first problem.

2. The menu bar button needs also a customized icon (the same as below,
published to the forms lib.) which isn't available as a faceid,
therefore a customized icon needs to be assigned to the menu bar button
(msoButtonIconAndCaption). That's my second problem.

I hope that anybody had the same problems in the past and came up whit
a solution.

Thanks
 
B

basel.sxaffolter

Eric,

1) you mean that i should use the following "add" method:
objCDOItem.Fields.Add &H10800003, -1
But how do i specify the custom ico file?

2) Thanks, i'll go through that and i'll let you know.

Cheers
Sascha
 
G

Guest

You need to use a custom form to use custom icons, so it has to be set in the
form designer. Am I correct in assuming that you want the same form to use
several icons to represent different states? AFAIK, custom forms only
support using one custom icon, so if you want to change it you are limited to
the built-in ones and the single icon used by the custom form.
 
B

basel.sxaffolter

I used a custom form to assign a custom icon to a message, one custom
form with one custom message class and one custom icon. It works fine
as long as the message has not the reply/forward status set. I also
prefer the way to use a custom form for this however, it should work
also on these types of messages.

Sascha
 
G

Guest

Right - Outlook changes the message icon to the reply/forward icon. You'd
have to change it back after those actions somehow.
 
B

basel.sxaffolter

Eric,

thanks for your hints, i tested the KB article (How To Set the Mask and
Picture Properties for Office XP CommandBars) regarding the custom icon
in the menu bar, that all works fine.

To my second question, i found out a way to change a message icon using
a custom form with a custom icon when the message has the reply/forward
flag set. First you have to change the message class to your custom
message class which is published as a custom form in your Org./Pers.
lib. Then you have to set the PR_ICON_INDEX MAPI prop. tag to -1 to use
a the custom icon. This will then assign the custom icon, derived from
the custom message class, published as a custom form in your Org./Pers.
forms lib.

here's the part of the code which is doing the job:

If Not .MessageClass = "IPM.Note.MyMessageClass"
Then

.MessageClass = "IPM.Note.MyMessageClass"
.Save

szEntryID = .EntryID
szStoreID = .Parent.StoreID

Set objCDOItem =
objCDOSession.GetMessage(szEntryID, szStoreID)
objCDOItem.Fields.Add &H10800003, -1
objCDOItem.Update True

End If

Cheers
Sascha
 
G

Guest

If you want to change the icon when the user replies/forward the item, one
way is to make a wrapper to trap every time an e-mail window opens so that
you can then trap the Reply/Forward events:

Getting a Handle on Your E-mails with VBA:
http://blogs.officezealot.com/legault/articles/2224.aspx

You'd have to go further though to trap if a user is replying/forwarding the
message from a folder view, probably via the Explorer.SelectionChange event.
This may not work though - I'm a little foggy this morning and can't fully
reason through whether you can adequately determine whether the Reply/Forward
events are trappable for a selected message in this situation (I'm sure I've
tried this before but can't remember). These events may be trappable from
VBScript within the custom form itself otherwise. Try it and let me know!
 
M

Michael Bauer

Am Tue, 23 Aug 2005 08:01:04 -0700 schrieb Eric Legault [MVP - Outlook]:

Eric, I know the foggy almost every morning :)

For trapping from the folder view you just need to catch the button
clicks. This works even for the context menu.

--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
If you want to change the icon when the user replies/forward the item, one
way is to make a wrapper to trap every time an e-mail window opens so that
you can then trap the Reply/Forward events:

Getting a Handle on Your E-mails with VBA:
http://blogs.officezealot.com/legault/articles/2224.aspx

You'd have to go further though to trap if a user is replying/forwarding the
message from a folder view, probably via the Explorer.SelectionChange event.
This may not work though - I'm a little foggy this morning and can't fully
reason through whether you can adequately determine whether the Reply/Forward
events are trappable for a selected message in this situation (I'm sure I've
tried this before but can't remember). These events may be trappable from
VBScript within the custom form itself otherwise. Try it and let me
know!
 
G

Guest

Good point Michael - that's sure to work.

--
Eric Legault - B.A, MCP, MCSD, Outlook MVP
Try Picture Attachments Wizard for Outlook! http://tinyurl.com/ckytm
Job: http://www.imaginets.com
Blog: http://blogs.officezealot.com/legault/


Michael Bauer said:
Am Tue, 23 Aug 2005 08:01:04 -0700 schrieb Eric Legault [MVP - Outlook]:

Eric, I know the foggy almost every morning :)

For trapping from the folder view you just need to catch the button
clicks. This works even for the context menu.

--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
If you want to change the icon when the user replies/forward the item, one
way is to make a wrapper to trap every time an e-mail window opens so that
you can then trap the Reply/Forward events:

Getting a Handle on Your E-mails with VBA:
http://blogs.officezealot.com/legault/articles/2224.aspx

You'd have to go further though to trap if a user is replying/forwarding the
message from a folder view, probably via the Explorer.SelectionChange event.
This may not work though - I'm a little foggy this morning and can't fully
reason through whether you can adequately determine whether the Reply/Forward
events are trappable for a selected message in this situation (I'm sure I've
tried this before but can't remember). These events may be trappable from
VBScript within the custom form itself otherwise. Try it and let me
know!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top