This project has moved and is read-only. For the latest updates, please go here.
/*
   list inbox folder in Outlook
   taken from Example01.cs
*/
private void Example01Main()
{ 
   // start outlook
   Outlook.Application outlookApplication = new Outlook.Application();
   
   // get inbox 
   Outlook._NameSpace outlookNS = outlookApplication.GetNamespace("MAPI");
   Outlook.MAPIFolder inboxFolder =  _
   outlookNS.GetDefaultFolder(OlDefaultFolders.olFolderInbox);

   // setup gui
   listView1.Items.Clear();
   labelItemsCount.Text = string.Format("You have {0} e-mails.", inboxFolder.Items.Count);
   
   // we fetch the inbox folder items.      
   foreach (COMObject item in inboxFolder.Items)      
   {      
       // not every item in the inbox is a mail item
      Outlook.MailItem mailItem = item as Outlook.MailItem;
      if (null != mailItem)
      { 
          ListViewItem newItem =
listViewInboxFolder.Items.Add(mailItem.SenderName); newItem.SubItems.Add(mailItem.Subject); } } // close outlook and dispose outlookApplication.Quit(); outlookApplication.Dispose(); }

Last edited Jun 13, 2012 at 10:22 AM by SebastianDotNet, version 17

Comments

No comments yet.