Solved

C# code to retrieve mail messages from MS Exchange server

Posted on 2010-08-31
4
774 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
outlook error send and receive 15 97
Restriction incoming email to Exchange 2010 4 35
ASP.NET data base connection 35 46
OUTLOOK 2016 receive time interval 8 57
Are you unable to connect or configure Hotmail email account in Microsoft Outlook 2010, 2007? Or Outlook.com emails are not downloading to Outlook? Lets’ see the problem and resolve Outlook Connector error syncing folder hierarchy (0x8004102A).
How to resolve IMCEAEX NDRs in Exchange or Exchange Online related to invalid X500 addresses.
To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
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…

696 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