Honestly speaking I love programming Outlook, especially Outlook 2003 which provides enough flexibility to integrate with your applications.
This code of snippet is a small example of how you can fetch inbox messages. Before trying this piece of code add a reference for Microsoft Outlook 11.0 Object Library
Language : C#
// to prevent clashing from Application class.
using OutLookApp = Microsoft.Office.Interop.Outlook ;
OutLookApp.ApplicationClass objOutlook = new OutLookApp.ApplicationClass() ;
OutLookApp.NameSpace objNameSpace = objOutlook.GetNamespace("MAPI") ;
OutLookApp.MAPIFolder inboxFolder = objNameSpace.GetDefaultFolder(OutLookApp.OlDefaultFolders.olFolderInbox) ;
MessageBox.Show("You have " + inboxFolder.Items.Count + "e-mails.") ;
ListViewItem lvt = new ListViewItem() ;
int i = 0 ;
foreach(object obj in inboxFolder.Items)
{
OutLookApp.MailItem item = obj as OutLookApp.MailItem;
if(item != null)
{
lvt = this.listView1.Items.Add(item.Subject, i) ;
lvt.SubItems.Add(item.SenderName) ;
lvt.SubItems.Add(item.ReceivedTime.ToString()) ;
lvt.SubItems.Add(item.Body.ToString()) ;
i++ ;
}
}
Enjoy reading.
Cheers,
~Danish Sami