473,795 Members | 2,425 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

getting at users outlook inboxes programmaticall y

I am trying to get at different users inboxes programmaticall y (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.Applica tion oApp = new Outlook.Applica tion();

//Get MAPI namespace
Outlook.NameSpa ce oNS = oApp.GetNamespa ce("mapi");

oNS.Logon("user ", "password", false, true);

//Get Messages collection of Inbox
Outlook.MAPIFol der oInbox =
oNS.GetDefaultF older(Outlook.O lDefaultFolders .olFolderInbox) ;

Outlook.Items oItems = oInbox.Items;

int intTotalNumberO fItemsInInbox = 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 10621
"Mike P" <mi*******@gmai l.comwrote in message news:eq******** *****@TK2MSFTNG P05.phx.gbl...
>I am trying to get at different users inboxes programmaticall y (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.Applica tion oApp = new Outlook.Applica tion();

//Get MAPI namespace
Outlook.NameSpa ce oNS = oApp.GetNamespa ce("mapi");

oNS.Logon("user ", "password", false, true);

//Get Messages collection of Inbox
Outlook.MAPIFol der oInbox =
oNS.GetDefaultF older(Outlook.O lDefaultFolders .olFolderInbox) ;

Outlook.Items oItems = oInbox.Items;

int intTotalNumberO fItemsInInbox = 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*******@gmai l.comwrote in message
news:OD******** ******@TK2MSFTN GP06.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*******@gmai l.comwrote in message
news:%2******** ********@TK2MSF TNGP06.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
1235
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 database container and doing the following: 1. select file 2. select Get external data
5
9623
by: egholm | last post by:
I want to get a list of users from a specific AD group. I use this code: **************************************************************************************** SearchResult result; DirectorySearcher search = new DirectorySearcher(); search.Filter = String.Format("(cn={0})", groupName); search.PropertiesToLoad.Add("member"); result = search.FindOne();
0
1363
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 seem to exist. Here is a sample code: Outlook._Application olApp = new Outlook.ApplicationClass(); Outlook._NameSpace olNS = olApp.GetNamespace("MAPI");Outlook._Folders oFolders;
1
2671
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 oUser As DirectoryEntry = New DirectoryEntry(sQry) Return oUser.Properties("FullName").Value.ToString End Function how ever it fails on the production server. It throws a Unknown Error 0x80005000, and Exception String is:
3
2245
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
1583
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 applications. We have to use Outlook, and not Exchange, as the users are from many different organisations.
13
1718
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 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
0
1338
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
1188
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 reporting site. The email account is "MonthlySales". I thought that I could just log into the server with a different session: profileInfo = (object)string.Format("{0}\n{1}", MailServer, UserName); ns.Logon(profileInfo, Missing.Value,...
0
9672
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10437
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10164
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10001
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9042
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6780
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5437
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5563
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3723
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.