Discussion:
how to resolve MAPI_E_BAD_CHARWIDTH problem in GetMsgStoresTable call.
(too old to reply)
shivaraj
2007-03-13 11:01:54 UTC
Permalink
Hi,
I was trying to get mailbox store information using
"GetMsgStoresTable" MAPI call.

hr = pSession->GetMsgStoresTable(MAPI_UNICODE, &pTable);

But its failing as MAPI_E_BAD_CHARWIDTH. In net I found that this is
something to do with UNICODE ( The MAPI_UNICODE flag was set and MAPI
does not support Unicode at present.) but not getting how to fix this
so that I can get these store information. If any one is having sample
code or hint on proceeding further on this please let me know.
Regards,
Shivaraj
Dave Goldman [MSFT]
2007-03-13 19:08:19 UTC
Permalink
Don't pass MAPI_UNICODE as this will cause it to fail. You can pass NULL. Here is a small example for you and you can fix the rest of it but you get the idea.

// Declare a NULL SRowSet structure, and populate it with property values from one of the message stores by using IMAPITable::QueryRows. The following code retrieves the first (default) message store:


if (SUCCEEDED(hr = pSession->GetMsgStoresTable(0, &pTable)))
{

//Declare a NULL IMsgStore interface object, and open the message store by using IMAPISession::OpenMsgStore - making use of the SRowSet structure:
if (SUCCEEDED(hr = pTable->QueryRows(1, 0, &pSRowSet)))
{
if(FAILED(hr = pSession->OpenMsgStore(0, pSRowSet->aRow[0].lpProps[0].Value.bin.cb,
(ENTRYID *)pSRowSet->aRow[0].lpProps[0].Value.bin.lpb, NULL, 0, &pStore)))
{
print("OpenMsgStore");
return hr;
{

}
else
{
print("QueryRowserror");
return hr;
}

}
else
{
print("GetMsgStoresTable error");
return hr;
}


// If no longer needed, release the message stores table by calling IUnknown::Release on the table object, and free the memory allocated for the row set structure by calling FreeProws:
pTable->Release();
FreeProws(pSRowSet);
--
This posting is provided "AS IS" with no warranties, and confers no rights.

Dgoldman
http://blogs.msdn.com/dgoldman
Download OABInteg (http://gotdotnet.com/Community/UserSamples/Download.aspx?SampleGuid=A2338E73-F521-4071-9B1D-AAF49C346ACD)
"shivaraj" <***@gmail.com> wrote in message news:***@t69g2000cwt.googlegroups.com...
Hi,
I was trying to get mailbox store information using
"GetMsgStoresTable" MAPI call.

hr = pSession->GetMsgStoresTable(MAPI_UNICODE, &pTable);

But its failing as MAPI_E_BAD_CHARWIDTH. In net I found that this is
something to do with UNICODE ( The MAPI_UNICODE flag was set and MAPI
does not support Unicode at present.) but not getting how to fix this
so that I can get these store information. If any one is having sample
code or hint on proceeding further on this please let me know.
Regards,
Shivaraj
shivaraj
2007-03-14 09:08:07 UTC
Permalink
Post by Dave Goldman [MSFT]
Don't pass MAPI_UNICODE as this will cause it to fail. You can pass NULL. Here is a small example for you and you can fix the rest of it but you get the idea.
if (SUCCEEDED(hr = pSession->GetMsgStoresTable(0, &pTable)))
{
if (SUCCEEDED(hr = pTable->QueryRows(1, 0, &pSRowSet)))
{
if(FAILED(hr = pSession->OpenMsgStore(0, pSRowSet->aRow[0].lpProps[0].Value.bin.cb,
(ENTRYID *)pSRowSet->aRow[0].lpProps[0].Value.bin.lpb, NULL, 0, &pStore)))
{
print("OpenMsgStore");
return hr;
{
}
else
{
print("QueryRowserror");
return hr;
}
}
else
{
print("GetMsgStoresTable error");
return hr;
}
pTable->Release();
FreeProws(pSRowSet);
--
This posting is provided "AS IS" with no warranties, and confers no rights.
Dgoldmanhttp://blogs.msdn.com/dgoldman
Download OABInteg (http://gotdotnet.com/Community/UserSamples/Download.aspx?SampleGuid=A...)
Hi,
I was trying to get mailbox store information using
"GetMsgStoresTable" MAPI call.
hr = pSession->GetMsgStoresTable(MAPI_UNICODE, &pTable);
But its failing as MAPI_E_BAD_CHARWIDTH. In net I found that this is
something to do with UNICODE ( The MAPI_UNICODE flag was set and MAPI
does not support Unicode at present.) but not getting how to fix this
so that I can get these store information. If any one is having sample
code or hint on proceeding further on this please let me know.
Regards,
Shivaraj
Hi Dave,
Thanks a lot for your information and sample code. I was able to
resolve it using above said approach.
Now eventhough my code is workign fine, still i have got some more
doubts with respect to store in MAPI.

1. If I see system manager there is a clean hirarchy of organization -
Post by Dave Goldman [MSFT]
Administrative group -> Servers -> Storage Group -> Mailbox Store ->
MailBoxes. Through MAPI using "HrOpenExchangePrivateStore" I was able
to retrieve all mailbox information within a server (from all mailbox
stores). But my understanding was, using "GetMsgStoresTable" and
"OpenMsgStore" we should be able to get Mailbox store names. ( to get
clean mapping of StorageGroup -> MailboxStore -> MailBox mapping ).
But if i get PR_DISPLAY_NAME of each row in "GetMsgStoresTable", its
is returning something like "Mailbox - Administrator" and "Public
Folders". Any idea/views/suggestions will be appriciated as I am not
clear about MAPI MailboxStore concept.

2. I have a parent and child domain setup. My exchange server resides
in child domain. If I run my code ( C++ code to get mailbox
information ) with Administrative privilages of child domain, i am
able to retrieve all info. But if i create a user and make it as
domain admin and try to run my code, its failing during
"HrOpenExchangePrivateStore" call. Any extra permissions are required
for this?

Please let me know your views.

Regards,
Shivaraj

Loading...