Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

C# code to retrieve mail messages from MS Exchange server

Posted on 2010-08-31
4
Medium Priority
?
798 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 668 total points
ID: 33574218
0
 
LVL 6

Assisted Solution

by:nipunu
nipunu earned 668 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 664 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
If you troubleshoot Outlook for clients, you may want to know a bit more about the OST file before doing your next job. IMAP can cause a lot of drama if removed in the accounts without backing up.
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

926 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