468,554 Members | 1,891 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,554 developers. It's quick & easy.

getting at users outlook inboxes programmatically

I am trying to get at different users inboxes programmatically (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.Application oApp = new Outlook.Application();

//Get MAPI namespace
Outlook.NameSpace oNS = oApp.GetNamespace("mapi");

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

//Get Messages collection of Inbox
Outlook.MAPIFolder oInbox =
oNS.GetDefaultFolder(Outlook.OlDefaultFolders.olFo lderInbox);

Outlook.Items oItems = oInbox.Items;

int intTotalNumberOfItemsInInbox = oItems.Count;

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


*** Sent via Developersdex http://www.developersdex.com ***
Feb 19 '07 #1
5 10281
"Mike P" <mi*******@gmail.comwrote in message news:eq*************@TK2MSFTNGP05.phx.gbl...
>I am trying to get at different users inboxes programmatically (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.Application oApp = new Outlook.Application();

//Get MAPI namespace
Outlook.NameSpace oNS = oApp.GetNamespace("mapi");

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

//Get Messages collection of Inbox
Outlook.MAPIFolder oInbox =
oNS.GetDefaultFolder(Outlook.OlDefaultFolders.olFo lderInbox);

Outlook.Items oItems = oInbox.Items;

int intTotalNumberOfItemsInInbox = 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.

Feb 19 '07 #2
What do you mean by profile, I am not familiar with them?
*** Sent via Developersdex http://www.developersdex.com ***
Feb 19 '07 #3
"Mike P" <mi*******@gmail.comwrote in message
news:OD**************@TK2MSFTNGP06.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.

Feb 19 '07 #4
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 ***
Feb 20 '07 #5
"Mike P" <mi*******@gmail.comwrote in message
news:%2****************@TK2MSFTNGP06.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.
Feb 20 '07 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by egholm | last post: by
reply views Thread by mikael.palmblad | last post: by
1 post views Thread by John Daly | last post: by
4 posts views Thread by grimbeast | last post: by
13 posts views Thread by Mike P | last post: by
reply views Thread by Christian Heimes | last post: by
reply views Thread by NPC403 | last post: by
1 post views Thread by UniDue | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.