Click here to Skip to main content
15,886,258 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,

I am trying to access an outlook account and process all the present emails on some Inbox's subfolder:

I can access to this user's inbox, but not the subfolder.

C#
static void ReadMail()
    {


            Outlook.Application oApp = new Outlook.Application();

            Outlook.NameSpace oNS = oApp.GetNamespace("mapi");

            oNS.Logon(Missing.Value,Missing.Value,false,true);

                    Outlook.Recipient myRecipient = oNS.CreateRecipient("USERSMAILBOX");
                    myRecipient.Resolve();


                    Outlook.MAPIFolder oInbox = oNS.GetSharedDefaultFolder(myRecipient,                             Outlook.OlDefaultFolders.olFolderInbox);

                Outlook.Items oItems = oInbox.Items;

            Outlook.MailItem oMsg = (Outlook.MailItem)oItems.GetFirst();

                    MessageBox.Show(oMsg.Subject);

            oNS.Logoff();

            oMsg = null;
            oItems = null;
            oInbox = null;
            oNS = null;
            oApp = null;

    }


Right now I am able to printout the mails inside this user's inbox, but how can I fetch the mails inside a subfolder, named for example subFolder?

BR,
pgb
Posted

1 solution

 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900