' list inbox folder in outlook 
' taken from Example01.vb
'
Private Sub Example01Main()

   ' start outlook
   Dim outlookApplication = New Outlook.Application()

   ' get inbox 
   Dim outlookNS As Outlook._NameSpace = outlookApplication.GetNamespace("MAPI")
   Dim inboxFolder As Outlook.MAPIFolder = _
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 Dim items As Outlook._Items = inboxFolder.Items Dim item As COMObject = Nothing For Each item As COMObject In inboxFolder.Items ' not every item in the inbox folder is a mail item If (TypeName(item) = "MailItem") Then Dim mailItem As Outlook.MailItem = item Dim newItem As ListViewItem = listViewInboxFolder.Items.Add(mailItem.SenderName) newItem.SubItems.Add(mailItem.Subject) End If Next 'close outlook and dispose outlookApplication.Quit() outlookApplication.Dispose() End Sub

Last edited Jun 13, 2012 at 10:36 AM by SebastianDotNet, version 8