473,666 Members | 1,989 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Outlook fails to connect to Exchange Server profile

1 New Member
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 4386
RedSon
5,000 Recognized Expert Expert
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
1705
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 machine as Exchange; and apparently, one needs Outlook to configure a mail profile for SQL Server Agent. Is there, in fact, anything to worry about? If so, are there any work-arounds beside moving Exchange to another server? (we've only got one...
13
2160
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
6726
by: Srinivas | last post by:
hi all how to access the outlook user profiles through VB.net any help.... thanks in advanc Srinivas
14
4479
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 for another day's work. It logs everything and generates an email which it sends to a few people, issuing warnings if there were problems. Have you guessed the problem yet? Outlook 2003 / SP2 - "...Trying to send a mail...", "...use address
1
1263
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 without any problem, but the same thing fails miserably when used as a web service and gives the exception <?xml version="1.0" encoding="utf-8" ?> <string
6
21306
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 write: Dim oApp As New Outlook.Application
6
4750
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 you make is a service it all works except it will not sent the emails Attached is the public sub that should run, its the same code that in the stardard winform, both app's are using Threads
0
1596
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 using ProfMan.dll but this failed to save the profile when running as localsystem. - I tried to call MAPIInitialise passing the MAPI_NT_SERVICE - I also tried to connect by calling MAPILogonEx with the MAPI_NO_MAIL flags MAPI_NT_SERVICE (After...
2
3046
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 interface with MS Ecxhange or Outlook from a business application and add items to a user's calendar, task list, or at a minimum to set a follow up flag in an email. We are running Exchange 2003 and a variety of MS Outlook 2000 and 2003. We do have...
0
8445
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
8871
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...
0
8781
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8640
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
7386
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...
1
6198
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
4198
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
4369
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2011
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.