473,394 Members | 2,048 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,394 software developers and data experts.

Outlook fails to connect to Exchange Server profile

I am using the Microsoft Office 11.0 Object library to connect to outlook. My code is as follows:
Expand|Select|Wrap|Line Numbers
  1.      _ApplicationPtr application("Outlook.Application");
  2.     CComPtr<_NameSpace> ns;
  3.     CComPtr<_NameSpace> session;
  4.     hr = application->GetNamespace(CComBSTR("MAPI"),&session.p);
  5.     if(hr != S_OK) return hr;
  6.     hr = application->get_Session(&session.p);
  7.     if(hr != S_OK) return hr;
  8.     hr = session->Logon(CComVariant(profile),CComVariant(""),CComVariant(false),CComVariant(true));
  9.     if(hr != S_OK) return hr;
  10.     Outlook::OlExchangeConnectionMode connectionMode;
  11.     hr = session->get_ExchangeConnectionMode(&connectionMode);
  12.     CComPtr<Recipient> recp;
  13.     hr = session->get_CurrentUser(&recp.p);
  14.     CComBSTR name;
  15.     hr = recp->get_Name(&name.m_str);
  16.     return hr;
  17.  
The code is used to get the user-Name of the given profile. I am trying to Logon to an Exchange Server and get the userName.

When outlook is closed everything works fine. i.e given an Exchange Server profile i gets its userName.

But when outlook is open there arises two cases,
The outlook is open and an Exchange-Server connection is open. In this case also i get the proper userName.

But when outlook is open in some other session, say an POP3 for some other user, In this case, I fail to get the UserName of the ExchangeServer. Instead I get the UserName of the PoP3 account.

I have tried, using the various combinations for the Logon, but none seems to give the desired results.
Can some-one correct the code so that it returns always the correct user name.
Oct 20 '07 #1
1 4367
RedSon
5,000 Expert 4TB
You might have better luck if you try searching MSDN for your answer.
Nov 2 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: dananrg | last post by:
I would like to configure e-mail alerts on my SQL Server 2000 box. However, we also run Exchange on the same machine. I've been told there could be conflicts/issues having Outlook on the same...
13
by: Joseph Kormann | last post by:
I'm building an application to retrieve emails. Which is better to use: CDO or the Outlook library? Thanks.
9
by: Srinivas | last post by:
hi all how to access the outlook user profiles through VB.net any help.... thanks in advanc Srinivas
14
by: BillCo | last post by:
Hi folks, I have an a2k ap which is called from a batch file via task scheduler on at night - it runs a bunch of updates, imports stuff from other databases and generally preps the main backend...
1
by: isurug | last post by:
Hello All! I've been trying to come up with a web service which enables me to use outlook remotly with a machine which only has a web browser. I've tried this with windows forms and it worked...
6
by: Manuel | last post by:
Hi, Using the PIA "Microsoft Outlook 11 Object Library". I've noticed that the Logon method of the NameSpace Object is simply ignored. My Outlook 2003 is full updated. For example if I...
6
by: AMP | last post by:
I am trying to write a windows sevice that will send emails. The data is stored in a database and the service scans the database for new entries It work well as a stardard windows app, but when...
0
by: mrian84 | last post by:
I am trying to use Outlook Redemption 4.5 from a window service running as LocalSystem but I seem to have problems can anybody enlighten me on what to do? -I did try creating some profiles...
2
by: =?Utf-8?B?RU1jQ2FydGh5?= | last post by:
My organization currently has interfaces in place to generate MS Outlook emails from our business applications. I am trying to determine if it is possible and how difficult it might be to...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
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...
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...

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.