473,804 Members | 3,745 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 10622
"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
1236
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
9624
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
1364
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
2673
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
2248
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
1585
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
1719
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
9706
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
9584
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10323
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,...
1
7622
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5525
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
5654
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4301
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3822
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2995
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.