This blog is closing and I am moving to ‘Pranav on .NET’

Diversion to Pranav on .NET

I will be shutting-down this blog and moving to my new space Pranav on .NET where I will continue blogging not only about VSTO but also about cutting edge topics like Metro Apps, Windows Phone Apps, Azure etc. Lot to learn and implement. Actually I thought to have an exclusive space for me where I can write about the anything that I like. So bought some space and named it as Pranav on .NET. I hope I will have some good time there. Its been quite some time I am setting up the environment and blogging there. That’s the reason for no blog posts since few months here. But, its interesting to note that many people are visiting and commenting on the posts here. So I have migrate all the posts in this blog to my new website –

Hope you will enjoy my new home like Easy VSTO..!



Programmatically creating auto-format rule in Outlook

Here is the code snippet…

private void AutoFormat()
            AutoFormatRule afr;
            TableView tv;
            tv = applicationObject.ActiveExplorer().CurrentView;
            for (int i=1;i<=tv.AutoFormatRules.Count;i++)
                  AutoFormatRule rl =  tv.AutoFormatRules[i];
                        MessageBox.Show("Deleted" + rl.Name);
            afr = tv.AutoFormatRules.Add("TestAFRule");               
            afr.Font.Color = OlColor.olColorRed;                
            afr.Enabled = true;
      catch(System.Exception ex)
            MessageBox.Show("Err:" + ex.Message);


Is VSTO still alive?

Yes… you read it right!

Many people talk about Azure, HTML5, SilverLight, WindowsPhone 7, SharePoint etc. How many are talking about VSTO? Compared to other technologies, people who on talk on VSTO might be very less. But, the fact is that VSTO will exist and grow as long as there is a product called Microsoft Office exist!

Many people suggested me to retire from VSTO and choose some other technology as there is not much focus on it. But, VSTO is installed in my mind without ‘Uninstall’ option. Though I work on other technologies like Mobile Apps, ASP.NET etc., I always explore more about VSTO and love to get updates of it.

Actually, VSTO is not that bad as people think. It has very good features which address some issues which can’t be solved by other technologies. Some of the new features on Office 2010 like Backstage View, Ribbon Enhancements, Programmability refinements etc extends the programmability and make it ease.

When I have started working on VSTO, it is not shown in web search results (Bing or Google) until it is typed correctly. But now,  we have got many Video and Text Tutorials, Blogs, MSDN Library, exclusive forums to each office application and lot many. There is a lot of development in VSTO since last two years compared to before.

I thought to write a post on this after reading Ridi’s post – Is VSTO Dead?. Thanks Ridi!

Ridi recently spoke at Microsoft Innovation Roadtrip  and delivered several points on why Office programming is still valuable to give another benefits in organization productivity. He has shared few presentation decks on VSTO. Here is the Live Spaces link for it –

You can find Screen Casts, Tutorials and some downloadable content about VSTO 2010 here.

Happy Coding!

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.

const string TEST_PROPERTY = @"
 const int TEST_VALUE = 9;
 application = new MSOutlook.ApplicationClass();
 email =
 propertyAccessor = email.PropertyAccessor;
 propertyAccessor.SetProperty(TEST_PROPERTY, TEST_VALUE);
 object 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!

TechEd on the Road, Hyderabad

We are pleased to announce Tech∙Ed on the Road, where we put together the best sessions from Tech∙Ed India 2011 is scheduled on 22nd May, 2011 at Hyderabad. Thise event is not only about content and sessions – they also provide an opportunity for you to interact with and have your questions answered by the very people who work on these technologies day-in and day-out, and who can help you plan the features and architecture to support your business goals.

The content for this event will be targeted towards Software Developers and IT Professionals. Focus will be on technologies like ASP.NET MVC3, HTML5, Database, Internet Explorer 9, Windows 7, Web Platform, and Windows Azure.

Avail of these FREE Learning Opportunities and REGISTER for this exclusive series of events today.

Here is the agenda!

Time Developer Track IT Pro Track
09:30am – 10:00am Registration
10:00am – 11:00am Exploring ASP.NET
Speaker: Shravan
Virtualization at Microsoft
Speaker: Praveen
11:00am – 11:15am Tea Break
11:15am – 12:15pm Building rich web
applications using HTML5

Speaker: Harish
SQL Server Waits and
Queues – Your Gateway to Perf. Troubleshooting
Speaker: Pinal
12:15pm – 12:30pm Break
12:30pm – 01:30pm Building a social
networking portal on Windows Azure in 1 hour
Speaker: Saranya
Migrating to Windows
7 using P2V with MDT & Disk2VHD

Speaker: Aviraj
01:30pm – 02:30pm Lunch
02:30pm – 03:30pm TFS: Continuous
Global Delivery

Speaker: Vishal
Microsoft RemoteFX:
Rich Windows Desktop Experience for Session Virtualization and VDI
Speaker: Aviraj
03:30pm – 03:45pm Tea Break
03:45pm – 04:45pm JavaScript APIs and
enhancements with EcmaScript 5
Speaker: Krishna
Deploying your
applications on Windows 7
Speaker: Vijay
04:45pm – 05:00pm Break
05:00pm – 05:30pm Q & A

For more details, visit:

Date: 22nd May, 2011
Target Audience: Software Developers & IT Professionals

Microsoft R&D India Pvt. Ltd.,
MPR 1-5, Building 3,
Gachibowli, Hyderabad

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.

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.

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

Key points for updating a deployed office solution

You might have got a requirement to update the existing (deployed) office solution. If so, here are some key points related to signing certificates, that you need to keep in mind before doing this, which are suggested by msdn.

  1. Ensure that the solution is set up to provide the correct evidence for the security checks –
    • If the old solution is signed with a trusted certificate, sign the updated solution with the same certificate. If the certificate has expired or cannot be reused, use a certificate that is trusted at the enterprise level.
    • If the ClickOnce trust prompt was used for trust but the zone has been disabled, the solution will be disabled.
    • If the signing key was changed, trust must be re-established by using the ClickOnce trust prompt, or the certificate must be trusted at the enterprise level. If the trust is pre-established, the first version will be uninstalled and the updated version will be installed.
    • If the new certificate is trusted at the enterprise level, then the update takes place with no prompting.
    • If the new certificate is not trusted, a trust prompt is displayed to the user, if the prompt is allowed.
  2. Use the Publish Wizard to publish the updated Office solution to the same directory as the previous version.
    The Office solution is published to a folder at the same directory level as the old solution, but with an incremented version number. The application and deployment manifests are replaced, so the user is automatically directed to the new version the next time the solution checks for updates.
  3. Copy the solution files to the installation location, if it is different from the publish location. Keep the folders and files in the same relative positions.