getting at outlook inboxes programmatically

M

Mike P

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.olFolderInbox);

Outlook.Items oItems = oInbox.Items;

int intTotalNumberOfItemsInInbox = oItems.Count;

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

Guest

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.olFolderInbox);

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"/>

?
 
M

Mike P

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.
 
G

Guest

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
 
M

Mark Rae

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...
 
M

Mike P

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.
 
M

Mike P

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
 
M

Mark Rae

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/d...y/en-us/exchanchor/htms/msexchsvr_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
 
M

Mike P

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,015
Latest member
AmbrosePal

Latest Threads

Top