VSTO Outlook add-in: Categories not displaying correctly

T

TTT

An Outlook add-in is not working correctly on a client site.
The add-in should change the Categories of an Inbox email. We want the Categories to change to "Reg'd" when the user registers an Inbox email to our database via the add-in.

On a particular clients machine, this will work OK if the email has been opened, but will not make any change to the Categories if the email hasn't been opened, just selected and right clicked to access the add-in menu. In all cases, the email has been properly sent to the database. I am pretty sure the line of code to update Categories is being called in all instances.

I can't reproduce this error to debug on my machine, where Categories updates correctly in all cases.
All machines are on 2003 SP 3. The client is operating outlook via terminal services. Could this cause problems?

What can cause the Categories column to not update correctly in cases like this?.
Submitted using http://www.outlookforums.com
 
K

Ken Slovak - [MVP - Outlook]

It's certainly possible that terminal services has something to do with it,
but I don't see how. If your code is modifying specific items the category
is being added as a one-off on the items. So it shouldn't matter if the
category is in the master list as a custom category or not (those are stored
in the registry for Outlook 2003).

That it works when the change is made to an Inspector but not in an Explorer
context menu would also tend to indicate that TS has nothing to do with it,
the end result would be the same in either case.

I would add additional logging to see if the code is actually hit and does
run without exceptions. I'd also see what's different on that user's machine
than on others where the code runs. Addins and any other code that
interfaces with Outlook should be checked and disabled to see if they have
any effect.
 
T

TTT

I have found a related problem that I can reproduce. I think if I can fix this it may fix the original problem.

When I select multiple emails and register them to our database, only the first one selected has its Category changed to Reg'd. The others' behaviour depends on what mail server I am running. If I am on a POP account, the Category does not change. On a Microsoft Exchange Server at first the "Reg'd" doesn't show, but if I click on the email and then off, it appears.

The code is effectively like this, with my logging added to double check that the correct string is going in.



foreach (Outlook.MailItem mailItem in _emails)
{

mailItem.Save();


// Add the registered category to the mail item
CategoryHelper.AddCategory(mailItem, EmailManager.RegCategory);

MessageBox.Show(mailItem.Categories);

//We have to save the email if the properties are to stay.
mailItem.Save();

MessageBox.Show(mailItem.Categories);
}


If I run this with two emails selected the following happens

MessageBox Reg'd
The first email Category changes to Reg'd
MessageBox Reg'd
MessageBox Reg'd
No change in second email
MessageBox Reg'd

So the Save works for the first email, but not the second.

Any explanations?

kenslovak wrote on Wed, 07 April 2010 09:22
It's certainly possible that terminal services has something to do with it,
but I don't see how. .
Submitted using http://www.outlookforums.com
 
K

Ken Slovak - [MVP - Outlook]

I have no explanation for that and I've never seen anything like that
happen. Offhand the code looks OK but I have no idea what that helper is
doing or if it might cause an exception that might prevent adding a
category.
 

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