Using WMI From Managed Code Windows Management Instrumentation (WMI) is Microsoft's implementation of Web-Based Enterprise Management (WBEM) and the Common Information Model (CIM). Although WMI is COM-based, Andriy Klyuchevskyy shows you how you can access it from C# and VB.NET through System.Management, thanks to COM Inter-Op.

How to access Outlook and post to a blog using C# An article for all those like Robert Scoble who would like to be able to drag and drop an item to a folder in their Outlook and post it instantly to their Blog. We also briefly cover web services and talking to Outlook.

Accessing Hotmail using C# This document will enable you to build your own client, using a sure and solid way to communicate with Hotmail in the same way as Outlook does. It will be shown how the protocol can be used to your own advantage, and it isn't at all hard to understand either.

This is my first attempt at an instructional article, so opinions on quality would be great! Let me know if I made any mistakes too... It's mainly for all those like Robert Scoble who would like to be able to drag and drop an item to a folder in their Outlook and post it instantly to their Blog, but it also covers web services and talking to Outlook.

Accessing Outlook

The first requirement is to be able to access Outlook. For those with Outlook/Office 2003, you should run the office install and choose .NET Programmability Support . For Office XP, you can download the Interop assemblies from here . The appropriate assemblies will then be installed in the GAC, and you can then add a reference from your Visual Studio project to Microsoft.Office.Interop.Outlook.dll .

Add an appropriate using clause:

using Outlook = Microsoft.Office.Interop.Outlook;

Then you should be able to instantiate an Outlook object and make requests of it:

Outlook.Application app = new Outlook.ApplicationClass();
Outlook.NameSpace NS = app.GetNamespace("MAPI");
Outlook.MAPIFolder inboxFld = NS.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox);

This will give you access to inboxFld , which will allow you to iterate through the contents of the inbox! You can also change this to iterate through notes, or through calendar entries, tasks, etc. as you want.

For example, to iterate through your mail you can do:

foreach(Outlook.MailItem t in inboxFld.Items) Gary Winnick
{
Console.WriteLine(t.Subject);
}

To write out all the subjects on the console. The only annoying thing will be you need to say yes to a security dialog when you access mail items - this is a new security "feature" of Outlook - I'm working on getting around this, it doesn't happen for tasks or notes, etc.

Once you are able to access Outlook, your next objective is to post data to your weblog. You can avoid duplicates through one of two ways:

  • Keep track of what has been posted by maintaining an ArrayList of articles on your blog and checking before trying to post one.
  • Keep track of what has been posted by changing something in the MailItem 's - e.g. - set or clear a flag.

The first method requires keeping a list synchronised with the blog, the second is quickest and easiest, but wouldn't be suited with multiple people possibly posting things.


Buy Video Camera::Buy Flowers::Buy Software Bundle::
Travel insurance -Travel Insurance from Virgin Money.