0

I am reading Outlook mail using this code:

Microsoft.Office.Interop.Outlook.Application myApp = new Microsoft.Office.Interop.Outlook.Application();
Microsoft.Office.Interop.Outlook.NameSpace mapiNameSpace = myApp.GetNamespace("MAPI");
Microsoft.Office.Interop.Outlook.MAPIFolder myInbox = mapiNameSpace.GetDefaultFolder(Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderInbox);
int i = myInbox.Items.Count;
string strSubject = ((Microsoft.Office.Interop.Outlook.MailItem)myInbox.Items[i]).Subject;
string senderEmailid = ((Microsoft.Office.Interop.Outlook.MailItem)myInbox.Items[i]).SenderEmailAddress;
string ToEmailid = ((Microsoft.Office.Interop.Outlook.MailItem)myInbox.Items[i]).To;
string CcEmailid = ((Microsoft.Office.Interop.Outlook.MailItem)myInbox.Items[i]).CC;
string BccEmailid = ((Microsoft.Office.Interop.Outlook.MailItem)myInbox.Items[i]).BCC;
string CreationTime = ((Microsoft.Office.Interop.Outlook.MailItem)myInbox.Items[i]).CreationTime.ToString();

I am getting EntryIDCollection as well. How can I read the mail using EntryIDCollection instead of mail count i.e. i in my code?

I am using MS Outlook 2010.

Soner Gönül
  • 97,193
  • 102
  • 206
  • 364
Nitendra Jain
  • 489
  • 1
  • 7
  • 24

1 Answers1

1

You can use Namespace.GetItemFromID

Sam R.
  • 16,027
  • 12
  • 69
  • 122
Dmitry Streblechenko
  • 62,942
  • 4
  • 53
  • 78