How do I use C# to access an Outlook inbox (not my default inbox)?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Paige Watson
    New Member
    • Aug 2010
    • 1

    #1

    How do I use C# to access an Outlook inbox (not my default inbox)?

    I have read through this post, and found many like it.
    My problem is that the email inbox that I am trying to access is not my default inbox.
    There is a mail account that receives emails from a reporting site. The email account is "MonthlySal es".
    I thought that I could just log into the server with a different session:

    Code:
      profileInfo = (object)string.Format("{0}\n{1}", MailServer, UserName);
    
      ns.Logon(profileInfo, Missing.Value, false, true);
      string name = ns.CurrentUser.Name;
      inboxFolder = ns.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox);
    When this code runs:

    - Username and MailServer are correct.
    - profileInfo is correct

    - ns.Logon(...) runs without error...

    - "name" still shows MY logged in username
    - "inboxFolde r" still points to MY local inbox folder.

    How do I log into the "MonthlySal es" email account so that I can access it programatically ?
Working...