Solved

C# code to retrieve mail messages from MS Exchange server

Posted on 2010-08-31
4
765 Views
Last Modified: 2012-05-10
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.
0
Comment
Question by:cmh_rwhelan
4 Comments
 
LVL 16

Accepted Solution

by:
Stephan earned 167 total points
ID: 33574218
0
 
LVL 6

Assisted Solution

by:nipunu
nipunu earned 167 total points
ID: 33574952
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
                }
0
 
LVL 70

Assisted Solution

by:Éric Moreau
Éric Moreau earned 166 total points
ID: 33575168
0
 

Author Closing Comment

by:cmh_rwhelan
ID: 33578566
I will continue to p[ost here as the solution unfolds and I have a working app.

Thanks
0

Featured Post

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Following basic email etiquette rules will help you write a professional email and achieve a good, lasting impression with your contacts.
Read this checklist to learn more about the 15 things you should never include in an email signature.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
CodeTwo Sync for iCloud (http://www.codetwo.com/sync-for-icloud?sts=6554) automatically synchronizes your Outlook 2016, 2013, 2010 or 2007 folders with iCloud folders available via iCloud Control Panel. This lets you automatically sync them with…

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question