Advertisement

07.24.2008 at 01:00PM PDT, ID: 23593581
[x]
Attachment Details

CreateMsgService Failing....

Asked by exchnerd in Outlook Groupware Software, C++ Programming Language, Windows ATL / WTL / COM Programming

Tags: Microsoft, Outlook, 2003, VC++/ATL COM

Hi,

I am trying to add a new service to my profile using CreateMsgService. It fails with a return error code of -2147221245.

Here is the piece of code -

When I pass the MAPI_UNICODE flag, I don't get the MAPI_E_NOT_FOUND error but the new service is also not created.
My other APIs GetMsgServiceTable/GetProviderTable work only if I pass 0 instead of MAPI_UNICODE flag. However, the CreateMsgFails when I pass either of the values.

Any ideas???

TIA...Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
HRESULT hRes = S_OK;
	_NameSpacePtr spSession = NULL;
	m_spApp->GetNamespace(L"MAPI",&spSession);
 
	IUnknown* lpMAPIObject = NULL;
	LPMAPISESSION lpMAPISession = NULL;
 
	hRes = spSession->get_MAPIOBJECT(&lpMAPIObject);
	if (SUCCEEDED(hRes) && lpMAPIObject)
	{
		hRes = lpMAPIObject->QueryInterface(IID_IMAPISession,(LPVOID*)&lpMAPISession);
	}
 
	if (SUCCEEDED(hRes) && lpMAPISession)
	{
		LPPROFSECT lpPSGlobal = NULL;
		//hRes = lpMAPISession->OpenProfileSection((LPMAPIUID)pbGlobalProfileSectionGuid, NULL, 0, &lpPSGlobal);
		IMsgServiceAdmin* pMsgAdmin = NULL;
		hRes = lpMAPISession->AdminServices(0,&pMsgAdmin);
		IMAPITable* lppTable = NULL;
		LPMAPIERROR* lppError = NULL;
		
		if (hRes == S_OK)
		{
			//hRes = pMsgAdmin->GetMsgServiceTable(0,&lppTable);
			//pMsgAdmin->GetLastError(hRes,MAPI_UNICODE,lppError);
			//hRes = pMsgAdmin->GetProviderTable(0,&lppTable);
			//pMsgAdmin->GetLastError(hRes,MAPI_UNICODE,lppError);
			hRes = pMsgAdmin->CreateMsgService(TEXT("MSEMS"),NULL,0,MAPI_UNICODE);
			if (hRes == MAPI_E_NOT_FOUND)
				pMsgAdmin->GetLastError(hRes,MAPI_UNICODE,lppError);
		}
 
Loading Advertisement...
 
[+][-]07.24.2008 at 01:40PM PDT, ID: 22083310

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.24.2008 at 01:51PM PDT, ID: 22083406

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Outlook Groupware Software, C++ Programming Language, Windows ATL / WTL / COM Programming
Tags: Microsoft, Outlook, 2003, VC++/ATL COM
Sign Up Now!
Solution Provided By: exchnerd
Participating Experts: 1
Solution Grade: A
 
 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628