从outlook查看未读邮件

时间:2011-05-12 09:03:19

标签: asp.net outlook-2007

如何从asp.net 4.0查看outlook 2007的未读邮件? 我正在使用Express版本,并且我添加了对Microsoft Office对象库12的引用。我不确定应该编写什么代码来查看来自Outlook的uread邮件。 有什么帮助吗?

编辑1

我在stackoverflow Get unread Mails from Outlook

上有重复的问题

但是我在运行应用程序时遇到错误[运行时错误]:

System.IO.FileNotFoundException: Could not load file or assembly 'Office, Version=7.0.3300.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.

1 个答案:

答案 0 :(得分:0)

如何尝试使用以下代码

使用Outlook = Microsoft.Office.Interop.Outlook; //您需要添加Microsoft Office 11.0对象库才能使用它。我的版本11可能是旧版本或更高版本。

Outlook.Application outlook = new Outlook.ApplicationClass();
                Outlook.NameSpace ns = outlook.GetNamespace("Mapi");

                object _missing = Type.Missing;
                ns.Logon(_missing, _missing, false, true);


                Outlook.MAPIFolder inbox = ns.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox);

                int unread = inbox.UnReadItemCount;

                foreach (Outlook.MailItem mail in inbox.Items)
                {
                    string s = mail.Subject;
                } 
相关问题