开发者

Check Unread mail from outlook

How to check unread mail of outlook 2007 from asp.net 4.0 ? I am using Express edition and I have added reference of Microsoft office object library 12. I am not sure what should I code to see the uread mail from my outlook. Any help?

EDIT 1

I have got the duplicate question on stackoverflow Get unread Mails from Outlook

But I am getting error while running the application [Runtime Error]:

System.IO.FileNotFoundException: Could not load file or assembly 'Office, Version=7.0.3300.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its depe开发者_如何转开发ndencies. The system cannot find the file specified.


What About Giving the following code a try

using Outlook = Microsoft.Office.Interop.Outlook; //you need to add the Microsoft Office 11.0 Object Library to use this. mine is version 11 you might have an older or later version.

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;
                } 
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜