473,441 Members | 2,058 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,441 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 10579
"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...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.