473,398 Members | 2,380 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

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 1684
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

14
by: John | last post by:
Hi Is there a way to e-mail using outlook2002 from within vb.net without getting the nasty "An application is trying to access you outlook..." message? Thanks Regards
1
by: Roger | last post by:
I currently have an application that can monitor the Inbox of one mailbox running on a client using Outlook 2003. This is a standalone application that needs Outlook to be running in order to see...
2
by: Siv | last post by:
Hi, I have written an application which is used by sales staff when discussing products with their customers over the phone. It is a database application that holds detailed information about...
2
by: hsuntn | last post by:
I am grabbing Outlook MailItems using the Items property on my Outlook inbox. When I iterate through them, I notice that they are not ordered in ReceivedTime or CreationTime order. For example, ...
4
by: Brian Hampson | last post by:
I recently upgraded to Outlook 2007 B2TR and have found that I can no longer code against MAPI.DLL It's gone :( Using C#, I used to get the MAPI session, and from that I could change the out of...
1
by: =?Utf-8?B?cm9i?= | last post by:
C#.Net Outlook 2003 automation (programmatically) with Office.Interop.Outlook Problem: I have my outlook 2003 configured with multiple mailbox on my local machine. I want to specify the mailbox...
1
by: allbelonging | last post by:
C#.Net Outlook 2003 automation (programmatically) with Office.Interop.Outlook Problem: I have my outlook 2003 configured with multiple mailbox on my local machine. I want to specify the mailbox...
5
by: Mike P | last post by:
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...
4
by: musicloverlch | last post by:
Hi all, I have a database being used by 30 people and is split between the backend and frontend. The database has the ability to send e-mails through Outlook and I have even put Redemption on...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.