C# code to retrieve mail messages from MS Exchange server

I would like to have a C# app  that can go to my Outlook mailbox on the MS Exhange server and retrieve the mail messages, and save them as files so I can parse the body of the message for embedded data.
Who is Participating?
StephanConnect With a Mentor Lead Software EngineerCommented:
nipunuConnect With a Mentor Commented:
this works only in your outlook

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;
                    //get what you want
Éric MoreauConnect With a Mentor Senior .Net ConsultantCommented:
cmh_rwhelanAuthor Commented:
I will continue to p[ost here as the solution unfolds and I have a working app.

All Courses

From novice to tech pro — start learning today.