Namespace.Logon

  • Thread starter Thread starter Semut
  • Start date Start date
S

Semut

I have a COM add in. I try to call AddStore based on profile. Then, I use
Namespace.Logon("MyProfile", , true, true). Then, when I call the
AddStore(...). It appears that it did not addstore to the "MyProfile" that I
programmatically logon, instead, it will addstore to the default logon of
the Outlook. The Logon function does not seems to work on MAPI.. Any reason
why?

I am using the Application object where I obtain during OnConnection(..)
event handler. I have even try to create a new Application object but it
seems that the AddIn project does not allow it call the object could not be
created properly.

Anyone faced this problem before?

Below is my codes snippet

CComQIPtr<Outlook::_Application> spApp(g_AppDispatch);
CComBSTR nameSpaceType = T2W("MAPI");
CComPtr<Outlook::_NameSpace> spNameSpace;
spApp->GetNamespace(nameSpaceType,&spNameSpace);

CComVariant vEmpty(DISP_E_PARAMNOTFOUND, VT_ERROR);
CComVariant vTrue(VARIANT_TRUE);

spNameSpace->Logon(vtProfileName, vEmpty, vTrue, vTrue);

CComPtr<Outlook::_Folders> spFolders;
spNameSpace->get_Folders(&spFolders);

long lNoOfFolders =0;
spFolders->get_Count(&lNoOfFolders); //failed to get the correct profile
number of folders


thanks
 
Since only one instance of Outlook with one Outlook profile can be running
at a time, Namespace.Logon has no effect whatsoever in a COM add-in: Outlook
is already running one profile and can't run another.
 
I see. thanks for the enlightenment.

Sue Mosher said:
Since only one instance of Outlook with one Outlook profile can be running
at a time, Namespace.Logon has no effect whatsoever in a COM add-in:
Outlook is already running one profile and can't run another.

--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
Back
Top