Hi,
Thats what I am using to read email using C#:
outLookApp.NewMailEx += new ApplicationEvents_11_NewMailExEventHandler(outLookApp_NewMailEx);
Outlook.NameSpace olNameSpace = outLookApp.GetNamespace("mapi");
olNameSpace.Logon("xxxx", "xxxxx", false, true);
Outlook.MAPIFolder oInbox = olNameSpace.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox);
Outlook.Items oItems = oInbox.Items;
MessageBox.Show("Total : " + oItems.Count); //Total Itemin inbox
oItems = oItems.Restrict("[Unread] = true");
MessageBox.Show("Total Unread : " + oItems.Count); //Unread Items
Outlook.MailItem oMsg;
Outlook.Attachment mailAttachement;
for (int i = 0; i < oItems.Count; i++)
{
oMsg = (Outlook.MailItem)oItems.GetFirst();
MessageBox.Show(i.ToString());
MessageBox.Show(oMsg.SenderName);
MessageBox.Show(oMsg.Subject);
MessageBox.Show(oMsg.ReceivedTime.ToString());
MessageBox.Show(oMsg.Body);
The problem that I am facing is this application only works if the outlook is open on the machine. If outlook is closed it throws an exception: The server is not available. Contact your administrator if this condition persists. Is there anyway I can read email with outlook open. Thanks