We value your feedback.
Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!
I'm running this on my PC which has 3 Outlook Profiles: "Wade Chestnut" (default), "Recruiter" and "Archive". The "Recruiter" is the one I want to be able to select, but it doesn't prompt for a Profile and Inbox messages are pulled from my Account . I do receive the warning prompt from Outlook 2010 about a program trying to access e-mail addresses but never the prompt for the Profile even though I have the 3rd Logon parameter set to True which is "Show Dialog as Object".
Imports System.Reflection Imports Microsoft.Office.Interop Public Class Form1 Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click ' Create Outlook application. Dim oApp As Outlook.Application = New Outlook.Application() ' Get Mapi NameSpace. Dim oNS As Outlook.NameSpace = oApp.GetNamespace("MAPI") oNS.Logon("Recruiter", Missing.Value, True, True) ' Get Messages collection of Inbox. Dim oInbox As Outlook.MAPIFolder = oNS.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox) Dim oItems As Outlook.Items = oInbox.Items Label1.Text = "Total : " & oItems.Count ' Get unread e-mail messages. 'oItems = oItems.Restrict("[Unread] = true") Label2.Text = "Total Unread : " & oItems.Count ' Loop each unread message. Dim oMsg As Outlook.MailItem Dim i As Integer For i = 1 To oItems.Count oMsg = oItems.Item(i) DataGridView1.Rows.Add(i, oMsg.SenderName, oMsg.Subject, oMsg.ReceivedTime, oMsg.Body) Next ' Log off. oNS.Logoff() ' Clean up. oApp = Nothing oNS = Nothing oItems = Nothing oMsg = Nothing End Sub End Class