我正在使用以下代码阅读Outlook邮件:
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();
我也得到EntryIDCollection
。如何使用EntryIDCollection
而不是邮件计数(即我的代码中的i
)来阅读邮件?
我正在使用MS Outlook 2010。
答案 0 :(得分:1)
您可以使用Namespace.GetItemFromID