468,532 Members | 1,866 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

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

getting at 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
13 1539
On Feb 19, 10:58 am, Mike P <mike.p...@gmail.comwrote:
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 Developersdexhttp://www.developersdex.com***

<identity impersonate="true"/>

?

Feb 19 '07 #2
Identity impersonate could be used to hard code a single user's login
details, but I want to be able to have a situation where the user of the
page can select a user from a dropdown and be able to access their
emails.

*** Sent via Developersdex http://www.developersdex.com ***
Feb 19 '07 #3
"Mike P" <mi*******@gmail.comwrote in message
news:eT**************@TK2MSFTNGP04.phx.gbl...
//Create Outlook application
Outlook.Application oApp = new Outlook.Application();
http://support.microsoft.com/default...US;q257757#kb2

Read the "MORE INFORMATION" section, specifically the paragraph in bold...

There's a very strong possibility that this won't work at all in a
production environment...
Feb 19 '07 #4
On Feb 19, 2:42 pm, Mike P <mike.p...@gmail.comwrote:
Identity impersonate could be used to hard code a single user's login
details, but I want to be able to have a situation where the user of the
page can select a user from a dropdown and be able to access their
emails.

*** Sent via Developersdexhttp://www.developersdex.com***
Well, I've quickly checked the MSDN and now I'm not sure if you follow
the right way.

As I understand now, Outlook.Application is for automation with local
Outlook and I'm affraid with the current Outlook session.

For tasks like you wanted to do there is another way using Microsoft
Collaboration Data Objects (CDO) for Exchange 2000 Library.

Please check the following MSDN article
http://support.microsoft.com/?kbid=310206

you will need to know path to your Exchange, username and password

Feb 19 '07 #5
"Alexey Smirnov" <al************@gmail.comwrote in message
news:11**********************@t69g2000cwt.googlegr oups.com...
Well, I've quickly checked the MSDN and now I'm not sure if you follow
the right way.
The OP most definitely doesn't...
As I understand now, Outlook.Application is for automation with local
Outlook and I'm affraid with the current Outlook session.
Absolutely correct - simply not designed for server-side automation at
all...
For tasks like you wanted to do there is another way using Microsoft
Collaboration Data Objects (CDO) for Exchange 2000 Library.
And for later versions of Exchange too...
Feb 19 '07 #6
If I can't do what I am trying to do using the Outlook object model, do
you have any useful links with regard to doing this using Microsoft
Collaboration Data Objects (CDO) for Exchange 2000 Library, which I am
totally unfamiliar with.

*** Sent via Developersdex http://www.developersdex.com ***
Feb 19 '07 #7
"Mike P" <mi*******@gmail.comwrote in message
news:OH*************@TK2MSFTNGP04.phx.gbl...
If I can't do what I am trying to do using the Outlook object model, do
you have any useful links with regard to doing this using Microsoft
Collaboration Data Objects (CDO) for Exchange 2000 Library, which I am
totally unfamiliar with.
This should get you started:
http://msdn2.microsoft.com/en-us/library/ms986138.aspx

Although it relates to Exchange 2003, it will be very similar for Exchange
2000...
Feb 20 '07 #8
Mark,

I've just found out the version being used is 5.5...any links for this
version, or is it likely to be similar to 2003?
Thanks,

Mike
*** Sent via Developersdex http://www.developersdex.com ***
Feb 20 '07 #9
"Mike P" <mi*******@gmail.comwrote in message
news:ej*************@TK2MSFTNGP06.phx.gbl...
I've just found out the version being used is 5.5...
Wow! That's fairly old now...
any links for this version,
I guess the place to start would be here:
http://msdn.microsoft.com/library/de...vr_e55_sdk.asp
However, it's not exactly brimming with code samples...
or is it likely to be similar to 2003?
Not at all - the problem that you're going to come up against is that
access to Exchange 5.5 mailboxes is through CDO 1.21, and that isn't
supported in .NET, at least, not natively... I recall doing some VB6
programming against 5.5 about six years ago, but unfortunately can't locate
the code any more - I'm not even sure I still have it, not that it would
have helped you a great deal...

The link below suggests using COM InterOp - that *may* work...
http://www.thescripts.com/forum/thread300002.html
Feb 20 '07 #10
Thanks for the advice Mark, I'll check out those links ASAP.

Cheers,

Mike

*** Sent via Developersdex http://www.developersdex.com ***
Feb 21 '07 #11
Mark,

The first link in your last post goes to a 404 page 'location cannot be
found'....could you check this is the correct link?
Thanks,

Mike

*** Sent via Developersdex http://www.developersdex.com ***
Feb 21 '07 #12
"Mike P" <mi*******@gmail.comwrote in message
news:%2***************@TK2MSFTNGP04.phx.gbl...
The first link in your last post goes to a 404 page 'location cannot be
found'....could you check this is the correct link?
Works fine for me...
Feb 21 '07 #13
Strange...sometimes the link works and other times it doesn't...

*** Sent via Developersdex http://www.developersdex.com ***
Feb 22 '07 #14

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

14 posts views Thread by John | last post: by
2 posts views Thread by hsuntn | last post: by
4 posts views Thread by Brian Hampson | last post: by
4 posts views Thread by musicloverlch | last post: by
reply views Thread by NPC403 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.