Nitendra Jain
Nitendra Jain

Reputation: 499

How to access the MS Outlook mail using the EntryIDCollection?

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.

Upvotes: 0

Views: 855

Answers (1)

Dmitry Streblechenko
Dmitry Streblechenko

Reputation: 66286

You can use Namespace.GetItemFromID

Upvotes: 1

Related Questions