I am trying to access an Outlook mailbox from C # / Winforms. I have two separate mailboxes that my user profile can access. How can I encode it so that it retrieves only from a specific mailbox?
Here is what I have, but it only extracts information from the default account mailbox.
try
{
OutLook.Application oApp = new OutLook.Application();
OutLook.NameSpace oNS = (OutLook.NameSpace)oApp.GetNamespace("MAPI");
oNS.Logon(Missing.Value, Missing.Value, false, true);
OutLook.MAPIFolder theInbox = oNS.GetDefaultFolder(OutLook.OlDefaultFolders.olFolderInbox);
int count = theInbox.UnReadItemCount;
inboxLabel.Text = inboxLabel.Text + " " + count.ToString();
}
catch (Exception e)
{
MessageBox.Show(e.ToString());
}
I also need to specify specific folders along with mailboxes (e.g. above).
Thanks for the help in advance.
source
share