VSTO

PropertyAccessor in Exchange 2010 – issue and some workarounds

Following code works fine in Exchange 2003 and 2007. But fails in Exchange 2010, that too in Online Mode. There is an interesting discussion that happened recently in MSDN Forums on this topic. Just would like to share summary of it so that it will be helpful to them who are in need of it.

As of now, there is not work around, except changing mode of Exchange to Cache Mode. Some told that Microsoft is aware of this issue and working on it. A fix may be released with the next patches.

1const string TEST_PROPERTY = @”http://schemas.microsoft.com/mapi/string/
2{00020329-0000-0000-C000-000000000046}/TestProperty/00000003″;
3const int TEST_VALUE =9;
4application = new MSOutlook.ApplicationClass();
5email =
6(MSOutlook.MailItem)application.CreateItem(MSOutlook.0lItemType.olMailItem);
7propertyAccessor = email.PropertyAccessor;
8propertyAccessor.SetProperty(TEST_PROPERTY,TEST_VALUE);
9object objvalue =propertyAccessor.GetProperty(TEST_PROPERTY);

Here is another work around suggested by Joel…

“it looks like the it’s not completely resolved by simply using extended MAPI. I was trying to use IMAPIProps::GetProps() and specifying a single property tag with the ID specified, but the type not specified (using PT_UNSPECIFIED). As already noted, this works fine with Exchange 2007 online or cached mode, Exchange 2010 in cached mode, but not in Exchange 2010 online mode.

The workaround in this case is to specify the correct property type. But, since the managed PropertyAccessor.GetProperty() method does not know what the property type is ahead of time (at least for custom properties), I guess that could be why it’s failing. What I’m doing now is calling IMAPIProp::GetPropList() and finding the entry with matching property tag. Since GetPropList() returns the property type as well, I can now call GetProps() with the correct property type. This seems to work in Exchange 2010 online mode 🙂 ”

I think this is the simplest of all (which is suggested by Susanne Kapp via Wompi)…

For an easy workaround in VSTO, you can simply call the mailItem.Save() method after setting the property. But be aware of all the mails getting saved to your drafts folder if you don´t send the mail.

Hope this helps!

Deploying a COM Addin in 64-bit Office

Deployment alone is a hassle for VSTO Developers, especially beginners. In this, if one needs to deploy add-in in a 64-bit system is hectic. Here is a simple solution that I have used to debug and deploy add-ins in 64-bit Office.

You just need to follow these steps.
By default, the add-in will be registered with the respective office application. This is enough to run the application in debug mode. If we select ‘my add-in should be available to all users…’ option, it registers the add-in in the 32-bit global registry. This can be seen in RegEdit like this.
HKLMSoftwareWow6432NodeMicrosoftOffice\AddIns

But, 64-bit Office cannot see registries in this location. For the add-in to load correctly, the registry keys should be moved to the following location.
HKLMSoftwareMicrosoftOffice\AddIns

For deploying the application…

In Visual Studio 2010, you just need to update the TargetPlatform property to x64 in the Setup Project Properties. Your project is ready to be deployed in 64-bit versions of Office now!

If you are working on Visual Studio 2008, there is a bug in setup project which prevents the add-in from registering 64-bit COM components. A work around is suggested for this problem in Cannot load 64-bit self-registering DLL’s section in Troubleshooting Windows Installer Deployments article in MSDN. It describes how to manually write 64-bit registry keys for making your add-in to work in 64-bit Office.

For more details, go through this article: Deploying COM Add-ins for 64-bit Office using Visual Studio

RECENT POSTS

  • Building Apps for Office 2013 – Presentation
  • Can’t edit Excel Files in Windows Phone 8 after opening in Excel Web App?
  • What’s New in Excel 2013 – Presentation
  • Office 2013 Showcase in Hyderabad
  • New Update Released for Windows Phone – 7.10.8860.142

ARCHIVES

    Building Apps for Office 2013 – Presentation
    Can’t edit Excel Files in Windows Phone 8 after opening in Excel Web App?
    What’s New in Excel 2013 – Presentation
    Office 2013 Showcase in Hyderabad
    New Update Released for Windows Phone – 7.10.8860.142
    CATEGORIES
    Announcements C# Community Deployment General jQuery Office 2013 Outlook Troubleshooting Visual Studio Extensibility VSTO Windows 8 Windows Phone
    TAGS
    .NET architecture Bootstrapper C# ClickOnce Code Snippets Community Community Events Community Meetup Community Tech Days Concepts CTD deploying deploying add-in Deployment e-book ebook Enhancements Events Excel 2013 Exchange Accounts File Transfer FTP loading slowly Microsoft Microsoft Events msdn MSDN Forum MUGH Office12 Office14 Office 2010 Office 2013 Outlook Outlook 2003 Outlook 2007 Outlook Addins Performance PIA Tips Troubleshooting Visual Studio VSTO VSX Windows 8