473,386 Members | 1,733 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,386 software developers and data experts.

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

Similar topics

0
by: Bob Dydd | last post by:
Hi Everybody I am looking for a way to connect and disconnect to the Ms Outlook Inbox programmatically from a command button on a form . At the moment it is easy enough to do by going to the...
5
by: egholm | last post by:
I want to get a list of users from a specific AD group. I use this code: **************************************************************************************** SearchResult result;...
0
by: mikael.palmblad | last post by:
I can't get this thing to work. I'm trying to export contacts to a specific folder in Outlook but I can't get the folder. I have several examples on how to do it by there is one function that don't...
1
by: John Daly | last post by:
The following code works fine on my development pc: Public Shared Function GetFullName(ByVal userID As String) As String Dim sQry As String = "WinNT://" & userID.Replace("\", "/") & ",user" Dim...
3
by: Chakkaradeep | last post by:
Hi all, How to retrieve Users Names and also restrict internet access to a specific users using C# ? Thanks. Regards, C.C.Chakkaradeep
4
by: grimbeast | last post by:
Hi We are currently in the process of writing an asp.net application. As part of the project we need to establish, some sort of communication between the application and the users Outlook...
13
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...
0
by: Christian Heimes | last post by:
python dev wrote: The /sys and /proc file system provide all the information you need: for line in open("/proc/mounts"): ... Christian
0
by: Paige Watson | last post by:
I have read through this post, and found many like it. My problem is that the email inbox that I am trying to access is not my default inbox. There is a mail account that receives emails from a...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...

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.