Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
platform
active.directory
adsi
adsi.iis-admin
base
com_ole
complus_mts
component_svcs
database
directx
gdi
graphics_mm
internet.client
internet.server
internet.server.isapi-dev
localization
mapi
messaging
msi
mslayerforunicode
multimedia
networking
networking.ipv6
sdk_install
security
shell
telephony.tapi_2
telephony.tapi_3
telephony.tsp
telephony.wte
tools
ui
ui_shell
win_base_svcs
win16
  
 
date: Fri, 14 Mar 2008 02:34:00 -0700,    group: microsoft.public.platformsdk.mapi        back       


IMAPISession::SetDefaultStore   
Hi,

I´m trying to setup a profil for Outlook with MAPI.
So far so good. It´s no problem to create the profil an editing this.
But i want to use a pst-file as default store and always get an error.

"This informationstorage can´t used as standardstore" 

But in the account-settings I can chose the pst-file.

I´m using the following function:

Any suggestions???

HRESULT SetDefStore(char* ProfileName) {
	LPMAPISESSION lpMAPISession = NULL;
	LPMAPITABLE pStoresTbl = NULL;
	LPSRowSet   pRows = NULL;
	static      SRestriction sres;
	HRESULT     hRes;
	LPMDB       lpTempMDB = NULL;
	enum {EID, NAME, DEFSTORE, NUM_COLS};
	LPSRow      prow = NULL;

	static SizedSPropTagArray(NUM_COLS,sptCols) = {NUM_COLS, PR_ENTRYID, 
PR_DISPLAY_NAME, PR_DEFAULT_STORE};
	
	hRes = MAPIInitialize(NULL);
    if (HR_FAILED(hRes)) {
		printf("MAPIInitialize failed: %X\n",hRes);
        return hRes;
    }

	hRes = MAPILogonEx(0, ProfileName, NULL, MAPI_NO_MAIL | MAPI_NEW_SESSION | 
MAPI_EXTENDED, &lpMAPISession);
	
	hRes = lpMAPISession->lpVtbl->GetMsgStoresTable(lpMAPISession, 0, 
&pStoresTbl);
	if (HR_FAILED(hRes)) {
		printf("GetMsgStoresTable failed: %X\n",hRes);
		goto quit;
    }

	hRes = HrQueryAllRows(
		pStoresTbl, //Table to query
		(LPSPropTagArray) &sptCols, //Which columns to get
		NULL, //No Restriction
		NULL, //No sort order
		0, //Max number of rows (0 means no limit)
		&pRows); //Array to return

	if (HR_FAILED(hRes)) {
		printf("HrQueryAllRows failed: %X\n",hRes);
		goto quit;
    }

    for(prow = pRows->aRow; prow < pRows->aRow + cProviders; ++prow) {
        Assert(prow->cValues == cptaSvc);
        Assert(prow->lpProps[EID].Value.bin.lpb == PR_ENTRYID);
        Assert(prow->lpProps[NAME].ulPropTag == PR_DISPLAY_NAME);
        Assert(prow->lpProps[DEFSTORE].ulPropTag == PR_DEFAULT_STORE);
		if(prow->lpProps[DEFSTORE].Value.b == FALSE) {
			hRes = lpMAPISession->lpVtbl->SetDefaultStore(lpMAPISession,
				MAPI_DEFAULT_STORE,					//Establishes the message store as the session 
default. Updates the message store's status table row by setting the 
STATUS_DEFAULT_STORE flag in the PR_RESOURCE_FLAGS column.
				prow->lpProps[EID].Value.bin.cb,
				(LPENTRYID)prow->lpProps[EID].Value.bin.lpb);
			if (HR_FAILED(hRes)) {
				printf("SetDefaultStore failed: %X\n",hRes);
				goto quit;
			}
		}
	}
	quit:

	FreeProws(pRows);
	UlRelease(pStoresTbl);
	if (FAILED(hRes)){
		HRESULT hr;
		LPMAPIERROR lpError;
		hr = lpMAPISession->lpVtbl->GetLastError(lpMAPISession, hRes,0,&lpError);
		if (!hr){
			printf("%s\n%s\n",lpError->lpszError,lpError->lpszComponent);
			MAPIFreeBuffer(lpError);
		}
	}
	MAPIUninitialize();
	return hRes;
}
date: Fri, 14 Mar 2008 02:34:00 -0700   author:   MR

Re: IMAPISession::SetDefaultStore   
Is that the actual error returned by SetDefaultStore?
Have you tried to use HrValidateIPMSubtree first?
Why do you need to log to that profile? If you create a profile with a 
single store, Outlook will automatically make that the default store and 
create teh default folders when it first uses the profile.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy  - Outlook, CDO
and MAPI Developer Tool

"MR"  wrote in message 
news:9F24FA0E-EC7D-4948-917F-1AEC86F55C52@microsoft.com...
> Hi,
>
> I´m trying to setup a profil for Outlook with MAPI.
> So far so good. It´s no problem to create the profil an editing this.
> But i want to use a pst-file as default store and always get an error.
>
> "This informationstorage can´t used as standardstore"
>
> But in the account-settings I can chose the pst-file.
>
> I´m using the following function:
>
> Any suggestions???
>
> HRESULT SetDefStore(char* ProfileName) {
> LPMAPISESSION lpMAPISession = NULL;
> LPMAPITABLE pStoresTbl = NULL;
> LPSRowSet   pRows = NULL;
> static      SRestriction sres;
> HRESULT     hRes;
> LPMDB       lpTempMDB = NULL;
> enum {EID, NAME, DEFSTORE, NUM_COLS};
> LPSRow      prow = NULL;
>
> static SizedSPropTagArray(NUM_COLS,sptCols) = {NUM_COLS, PR_ENTRYID,
> PR_DISPLAY_NAME, PR_DEFAULT_STORE};
>
> hRes = MAPIInitialize(NULL);
>    if (HR_FAILED(hRes)) {
> printf("MAPIInitialize failed: %X\n",hRes);
>        return hRes;
>    }
>
> hRes = MAPILogonEx(0, ProfileName, NULL, MAPI_NO_MAIL | MAPI_NEW_SESSION |
> MAPI_EXTENDED, &lpMAPISession);
>
> hRes = lpMAPISession->lpVtbl->GetMsgStoresTable(lpMAPISession, 0,
> &pStoresTbl);
> if (HR_FAILED(hRes)) {
> printf("GetMsgStoresTable failed: %X\n",hRes);
> goto quit;
>    }
>
> hRes = HrQueryAllRows(
> pStoresTbl, //Table to query
> (LPSPropTagArray) &sptCols, //Which columns to get
> NULL, //No Restriction
> NULL, //No sort order
> 0, //Max number of rows (0 means no limit)
> &pRows); //Array to return
>
> if (HR_FAILED(hRes)) {
> printf("HrQueryAllRows failed: %X\n",hRes);
> goto quit;
>    }
>
>    for(prow = pRows->aRow; prow < pRows->aRow + cProviders; ++prow) {
>        Assert(prow->cValues == cptaSvc);
>        Assert(prow->lpProps[EID].Value.bin.lpb == PR_ENTRYID);
>        Assert(prow->lpProps[NAME].ulPropTag == PR_DISPLAY_NAME);
>        Assert(prow->lpProps[DEFSTORE].ulPropTag == PR_DEFAULT_STORE);
> if(prow->lpProps[DEFSTORE].Value.b == FALSE) {
> hRes = lpMAPISession->lpVtbl->SetDefaultStore(lpMAPISession,
> MAPI_DEFAULT_STORE, //Establishes the message store as the session
> default. Updates the message store's status table row by setting the
> STATUS_DEFAULT_STORE flag in the PR_RESOURCE_FLAGS column.
> prow->lpProps[EID].Value.bin.cb,
> (LPENTRYID)prow->lpProps[EID].Value.bin.lpb);
> if (HR_FAILED(hRes)) {
> printf("SetDefaultStore failed: %X\n",hRes);
> goto quit;
> }
> }
> }
> quit:
>
> FreeProws(pRows);
> UlRelease(pStoresTbl);
> if (FAILED(hRes)){
> HRESULT hr;
> LPMAPIERROR lpError;
> hr = lpMAPISession->lpVtbl->GetLastError(lpMAPISession, hRes,0,&lpError);
> if (!hr){
> printf("%s\n%s\n",lpError->lpszError,lpError->lpszComponent);
> MAPIFreeBuffer(lpError);
> }
> }
> MAPIUninitialize();
> return hRes;
> }
>
date: Sun, 16 Mar 2008 00:48:13 -0700   author:   Dmitry Streblechenko

Re: IMAPISession::SetDefaultStore   
Yes, it is the actual error.
I logon with a specific profile, because it´s a new profile and mayby a 
default profile still exists.
date: Mon, 17 Mar 2008 00:42:00 -0700   author:   MR

Re: IMAPISession::SetDefaultStore   
Now if´ve extended my sourcecode with HrVaildateIPMSubtree, but get the same 
error.

HRESULT SetDefStore(char* ProfileName) {
	LPMAPISESSION lpMAPISession = NULL;
	LPMAPITABLE pStoresTbl = NULL;
	LPSRowSet   pRows = NULL;
	static      SRestriction sres;
	HRESULT     hRes;
	LPMDB       lpTempMDB = NULL;
	enum {EID, NAME, DEFSTORE, NUM_COLS};
	LPSRow      prow = NULL;

	static SizedSPropTagArray(NUM_COLS,sptCols) = {NUM_COLS, PR_ENTRYID, 
PR_DISPLAY_NAME, PR_DEFAULT_STORE};
	
	hRes = MAPIInitialize(NULL);
	if (HR_FAILED(hRes)) {
		printf("MAPIInitialize failed: %X\n",hRes);
		return hRes;
	}

	hRes = MAPILogonEx(0, ProfileName, NULL, MAPI_NO_MAIL | MAPI_EXTENDED | 
MAPI_NEW_SESSION, &lpMAPISession);
	
	hRes = lpMAPISession->lpVtbl->GetMsgStoresTable(lpMAPISession, 0, 
&pStoresTbl);
	if (HR_FAILED(hRes)) {
		printf("GetMsgStoresTable failed: %X\n",hRes);
		goto quit;
	}

	hRes = HrQueryAllRows(
		pStoresTbl, //Table to query
		(LPSPropTagArray) &sptCols, //Which columns to get
		NULL, //No Restriction
		NULL, //No sort order
		0, //Max number of rows (0 means no limit)
		&pRows); //Array to return

	if (HR_FAILED(hRes)) {
		printf("HrQueryAllRows failed: %X\n",hRes);
		goto quit;
	}

	for(prow = pRows->aRow; prow < pRows->aRow + cProviders; ++prow) {
		Assert(prow->cValues == cptaSvc);
		Assert(prow->lpProps[EID].Value.bin.lpb == PR_ENTRYID);
		Assert(prow->lpProps[NAME].ulPropTag == PR_DISPLAY_NAME);
		Assert(prow->lpProps[DEFSTORE].ulPropTag == PR_DEFAULT_STORE);
		if(prow->lpProps[DEFSTORE].Value.b == FALSE) {
			LPMDB FAR * lppMDB;

			hRes = lpMAPISession->lpVtbl->OpenMsgStore(lpMAPISession, 0, 
prow->lpProps[EID].Value.bin.cb, (LPENTRYID)prow->lpProps[EID].Value.bin.lpb, 
NULL, MAPI_BEST_ACCESS, lppMDB);
			hRes = HrValidateIPMSubtree( *lppMDB, MAPI_FULL_IPM_TREE | 
MAPI_FORCE_CREATE, 0, NULL, NULL);
			
			hRes = lpMAPISession->lpVtbl->SetDefaultStore(lpMAPISession,
				MAPI_DEFAULT_STORE,					//Establishes the message store as the session 
default. Updates the message store's status table row by setting the 
STATUS_DEFAULT_STORE flag in the PR_RESOURCE_FLAGS column. 
				prow->lpProps[EID].Value.bin.cb,
				(LPENTRYID)prow->lpProps[EID].Value.bin.lpb);
			
			if (HR_FAILED(hRes)) {
				printf("SetDefaultStore failed: %X\n",hRes);
				goto quit;
			}
		}
	}
	quit:

	FreeProws(pRows);
	UlRelease(pStoresTbl);
	if (FAILED(hRes)){
		HRESULT hr;
		LPMAPIERROR lpError;
		hr = lpMAPISession->lpVtbl->GetLastError(lpMAPISession, hRes,0,&lpError);
		if (!hr){
			printf("%s\n%s\n",lpError->lpszError,lpError->lpszComponent);
			MAPIFreeBuffer(lpError);
		}
	}
	MAPIUninitialize();
	return hRes;
}
date: Mon, 17 Mar 2008 03:55:01 -0700   author:   MR

Re: IMAPISession::SetDefaultStore   
How do you know that the store you are making the default one is the one you 
just added?
What othe rstores doi you have in that profile? Is there a chance you are 
dealing with a store that cannot be made default (such sa the PF store)?

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy  - Outlook, CDO
and MAPI Developer Tool

"MR"  wrote in message 
news:B49B7811-B731-4314-8157-036C706616BA@microsoft.com...
> Now if´ve extended my sourcecode with HrVaildateIPMSubtree, but get the 
> same
> error.
>
> HRESULT SetDefStore(char* ProfileName) {
> LPMAPISESSION lpMAPISession = NULL;
> LPMAPITABLE pStoresTbl = NULL;
> LPSRowSet   pRows = NULL;
> static      SRestriction sres;
> HRESULT     hRes;
> LPMDB       lpTempMDB = NULL;
> enum {EID, NAME, DEFSTORE, NUM_COLS};
> LPSRow      prow = NULL;
>
> static SizedSPropTagArray(NUM_COLS,sptCols) = {NUM_COLS, PR_ENTRYID,
> PR_DISPLAY_NAME, PR_DEFAULT_STORE};
>
> hRes = MAPIInitialize(NULL);
> if (HR_FAILED(hRes)) {
> printf("MAPIInitialize failed: %X\n",hRes);
> return hRes;
> }
>
> hRes = MAPILogonEx(0, ProfileName, NULL, MAPI_NO_MAIL | MAPI_EXTENDED |
> MAPI_NEW_SESSION, &lpMAPISession);
>
> hRes = lpMAPISession->lpVtbl->GetMsgStoresTable(lpMAPISession, 0,
> &pStoresTbl);
> if (HR_FAILED(hRes)) {
> printf("GetMsgStoresTable failed: %X\n",hRes);
> goto quit;
> }
>
> hRes = HrQueryAllRows(
> pStoresTbl, //Table to query
> (LPSPropTagArray) &sptCols, //Which columns to get
> NULL, //No Restriction
> NULL, //No sort order
> 0, //Max number of rows (0 means no limit)
> &pRows); //Array to return
>
> if (HR_FAILED(hRes)) {
> printf("HrQueryAllRows failed: %X\n",hRes);
> goto quit;
> }
>
> for(prow = pRows->aRow; prow < pRows->aRow + cProviders; ++prow) {
> Assert(prow->cValues == cptaSvc);
> Assert(prow->lpProps[EID].Value.bin.lpb == PR_ENTRYID);
> Assert(prow->lpProps[NAME].ulPropTag == PR_DISPLAY_NAME);
> Assert(prow->lpProps[DEFSTORE].ulPropTag == PR_DEFAULT_STORE);
> if(prow->lpProps[DEFSTORE].Value.b == FALSE) {
> LPMDB FAR * lppMDB;
>
> hRes = lpMAPISession->lpVtbl->OpenMsgStore(lpMAPISession, 0,
> prow->lpProps[EID].Value.bin.cb, 
> (LPENTRYID)prow->lpProps[EID].Value.bin.lpb,
> NULL, MAPI_BEST_ACCESS, lppMDB);
> hRes = HrValidateIPMSubtree( *lppMDB, MAPI_FULL_IPM_TREE |
> MAPI_FORCE_CREATE, 0, NULL, NULL);
>
> hRes = lpMAPISession->lpVtbl->SetDefaultStore(lpMAPISession,
> MAPI_DEFAULT_STORE, //Establishes the message store as the session
> default. Updates the message store's status table row by setting the
> STATUS_DEFAULT_STORE flag in the PR_RESOURCE_FLAGS column.
> prow->lpProps[EID].Value.bin.cb,
> (LPENTRYID)prow->lpProps[EID].Value.bin.lpb);
>
> if (HR_FAILED(hRes)) {
> printf("SetDefaultStore failed: %X\n",hRes);
> goto quit;
> }
> }
> }
> quit:
>
> FreeProws(pRows);
> UlRelease(pStoresTbl);
> if (FAILED(hRes)){
> HRESULT hr;
> LPMAPIERROR lpError;
> hr = lpMAPISession->lpVtbl->GetLastError(lpMAPISession, hRes,0,&lpError);
> if (!hr){
> printf("%s\n%s\n",lpError->lpszError,lpError->lpszComponent);
> MAPIFreeBuffer(lpError);
> }
> }
> MAPIUninitialize();
> return hRes;
> }
date: Mon, 17 Mar 2008 10:04:03 -0700   author:   Dmitry Streblechenko

Re: IMAPISession::SetDefaultStore   
I´m adding 2 services. An Exchange and a pst-file. 

As you can see, I´m  just searching for the occurrence from 
STATUS_DEFAULT_STORE == FALSE.  It´s not very fine, but the code is still on 
work and would get better ;)

the pst-file is an unicode-file, and i can chooe the pst-file in the 
dialogbox.
date: Mon, 17 Mar 2008 11:26:06 -0700   author:   MR

Re: IMAPISession::SetDefaultStore   
And when you add an EX mailbox, you get the PF store as well. It is not and 
cannot be set as a default store.
Do check the value of PR_MDB_PROVIDER to be MSPST_UID_PROVIDER rather than 
anything else (such as pbExchangeProviderPublicGuid)

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy  - Outlook, CDO
and MAPI Developer Tool

"MR"  wrote in message 
news:2D661DE2-2283-4BE3-96F6-00E2B2B01B76@microsoft.com...
> I´m adding 2 services. An Exchange and a pst-file.
>
> As you can see, I´m  just searching for the occurrence from
> STATUS_DEFAULT_STORE == FALSE.  It´s not very fine, but the code is still 
> on
> work and would get better ;)
>
> the pst-file is an unicode-file, and i can chooe the pst-file in the
> dialogbox.
date: Mon, 17 Mar 2008 12:26:53 -0700   author:   Dmitry Streblechenko

Re: IMAPISession::SetDefaultStore   
Ok, this works, but I´m getting an empty EntryID.
Any Idea?
date: Tue, 18 Mar 2008 01:30:01 -0700   author:   MR

Re: IMAPISession::SetDefaultStore   
Not the EntryID was the problem, a pointer was the problem.

thx for the help
date: Tue, 18 Mar 2008 03:53:01 -0700   author:   MR

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us