views:

314

answers:

1

I am about to embark on my first outlook 2007 plugin.

I would like to create a new tool bar that will have a button that will initially be disabled.

When the user selects a message the button should be enabled... but only if the email is of a certain type of email...

This is where I need your expert advice, is there a way to quickly flag an email in outlook, so that in the email select event you can look for a property of that email...

for example...

on_select if mail.type = "FromISP" then

I would prefer not to use the from field....

the other thing is during the send process I need to set the flag, I am doing this again using .net so I have full control over how the mail is created.

Any ideas would help...

Thanks

+2  A: 

enter code hereYou can wire up the on Application.ActiveExplorer().SelectionChange event, then look at the items in that collection (as the user may select more that one object). If you just want to enable your button only when one item is selected test for it, also if you just want to track Mail messages test for the MessageClass. Then cast the item into a MailItem where you can see all it properties.

For the send use Application.ItemSend event i think it will do the job .. (I tend to wrap the inspector my self.. ) You can then set your "flag" here. Setting a flag .. I would suggest using a userproperty on the item.

Update

On the send event add a userproperty to the email.

    UserProperty myprop = myItem.UserProperties.Add("MyPropName", olText);
    myprop.Value = "FlagOn" ;

Then in your selection event test for your flag by looking up the userproperty. Many people use the Mileage or Billing Fields of the Mailitem to store flags its simple but, if you run other addins or forms you find that they may use them as well and cause problems.

Update 2

Ok ... I think the way to go would be to add an X header in the ASP generation code then test for that looking at the email headers in your Addin using property accessors.

76mel
Mel, thanks for your answer - my main problem is how do I distinguish between an ordinary email, and one of my "special" emails?
JL
Added a bit more, but thinking about your comment are you trying to track email ?in and out of you domain ?
76mel
Problem is the email origin is not outlook, its an ASP.net server component that generates the emails
JL
Headers get lost on forwarding, so this is out of the question.
JL
The adding would need to look up the headers on the orginal email and the add them to the fwded email ? or are you trying to track email that get fwd by mail clients that dont have the addin?
76mel
Are user properties kept , even if message is sent lets say from outlook -> gmail -> outlook? or are they only preserved if the route is from outlook -> outlook?
JL
Some exchange to exchange does persist but it depends on how you config your envioment and what connectors gateways you use. Don rely on it.
76mel