getting at users outlook inboxes programmatically

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Mike P

    #1

    getting at users outlook inboxes programmatically

    I am trying to get at different users inboxes programmaticall y (see code
    below). It works fine, except for the fact that the logon line seems to
    always logon to my local account rather than logging on to other
    accounts on the network. Anybody know how to logon to other people's
    accounts using this method?

    //Create Outlook application
    Outlook.Applica tion oApp = new Outlook.Applica tion();

    //Get MAPI namespace
    Outlook.NameSpa ce oNS = oApp.GetNamespa ce("mapi");

    oNS.Logon("user ", "password", false, true);

    //Get Messages collection of Inbox
    Outlook.MAPIFol der oInbox =
    oNS.GetDefaultF older(Outlook.O lDefaultFolders .olFolderInbox) ;

    Outlook.Items oItems = oInbox.Items;

    int intTotalNumberO fItemsInInbox = oItems.Count;

    //Get unread e-mail messages
    oItems = oItems.Restrict ("[Unread] = true");
    int intTotalUnread = oItems.Count;




    *** Sent via Developersdex http://www.developersdex.com ***
  • Willy Denoyette [MVP]

    #2
    Re: getting at users outlook inboxes programmaticall y

    "Mike P" <mike.parr@gmai l.comwrote in message news:eqYvjyAVHH A.600@TK2MSFTNG P05.phx.gbl...
    >I am trying to get at different users inboxes programmaticall y (see code
    below). It works fine, except for the fact that the logon line seems to
    always logon to my local account rather than logging on to other
    accounts on the network. Anybody know how to logon to other people's
    accounts using this method?
    >
    //Create Outlook application
    Outlook.Applica tion oApp = new Outlook.Applica tion();
    >
    //Get MAPI namespace
    Outlook.NameSpa ce oNS = oApp.GetNamespa ce("mapi");
    >
    oNS.Logon("user ", "password", false, true);
    >
    //Get Messages collection of Inbox
    Outlook.MAPIFol der oInbox =
    oNS.GetDefaultF older(Outlook.O lDefaultFolders .olFolderInbox) ;
    >
    Outlook.Items oItems = oInbox.Items;
    >
    int intTotalNumberO fItemsInInbox = oItems.Count;
    >
    //Get unread e-mail messages
    oItems = oItems.Restrict ("[Unread] = true");
    int intTotalUnread = oItems.Count;
    >
    >
    >
    >
    *** Sent via Developersdex http://www.developersdex.com ***

    Logon takes a profile name as first parameter not a user name, the second parameter refers
    to the password for the profile.

    Willy.

    Comment

    • Mike P

      #3
      Re: getting at users outlook inboxes programmaticall y

      What do you mean by profile, I am not familiar with them?


      *** Sent via Developersdex http://www.developersdex.com ***

      Comment

      • Willy Denoyette [MVP]

        #4
        Re: getting at users outlook inboxes programmaticall y

        "Mike P" <mike.parr@gmai l.comwrote in message
        news:ODj5WwCVHH A.5108@TK2MSFTN GP06.phx.gbl...
        What do you mean by profile, I am not familiar with them?
        >
        >
        *** Sent via Developersdex http://www.developersdex.com ***

        Outlook is profile based and each user account has his own profile, a default profile is
        automatically created at first outlook run.
        If you need to connect to different mail accounts from a single windows session , you'll
        have to create additional outlook profiles. Note that you can only connect using a single
        profile at a time.
        Check outlook help for details.

        Willy.

        Comment

        • Mike P

          #5
          Re: getting at users outlook inboxes programmaticall y

          Can you tell me how to create profiles, and how to find out what my
          default profile is?



          *** Sent via Developersdex http://www.developersdex.com ***

          Comment

          • Willy Denoyette [MVP]

            #6
            Re: getting at users outlook inboxes programmaticall y

            "Mike P" <mike.parr@gmai l.comwrote in message
            news:%232b2QxMV HHA.5108@TK2MSF TNGP06.phx.gbl. ..
            Can you tell me how to create profiles, and how to find out what my
            default profile is?
            >
            >
            >
            *** Sent via Developersdex http://www.developersdex.com ***
            Please consult "outlook" help and the numerous knowledge base articles (like this:
            http://support.microsoft.com/kb/829918/), the right procedure to create profiles highly
            depends on the OS and outlook versions.

            Willy.


            Comment

            Working...