Solved

C# code to retrieve mail messages from MS Exchange server

Posted on 2010-08-31
4
757 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 69

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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Email signatures have numerous marketing benefits. Here are 8 top reasons to turn your email signature into a marketing channel.
Use email signature images to promote corporate certifications and industry awards.
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…
This Experts Exchange video Micro Tutorial shows how to tell Microsoft Office that a word is NOT spelled correctly. Microsoft Office has a built-in, main dictionary that is shared by Office apps, including Excel, Outlook, PowerPoint, and Word. When …

708 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now