|
|
|
date: Wed, 6 Aug 2008 01:02:08 -0700 (PDT),
group: microsoft.public.platformsdk.mapi
back
Re: How to skip Default/Special Folders of PST
Are you usre you are opening te *exact* same PST? How do you open it?
--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
"Sumit Khetrapal" wrote in message
news:806da2cf-42a8-4113-9069-58754b0e90a8@i24g2000prf.googlegroups.com...
> Hi,
>
> I am trying to read folder hierarchy of a PST (created using OL 2K3)
> containing only 1 folder . I am using following set of code to get the
> sub folders of Root folder (IPM_ROOT):
>
> IMAPITable *hierarchy = NULL;
> ULONG ulFlags = 0;
>
> hr = m_lpMapiFolder-
>>GetHierarchyTable(ulFlags, &hierarchy);
> if (FAILED(hr))
> {
> cout << "GetHierarchyTable failed with
> hr = " << hex << hr ;
> break;
> }
>
> The above call is returning 4 records named as Inbox, Outbox, Deleted
> Items and Fld1 (the one I exported).
> When I open the PST using OL Spy (GetHierarchyTable on Root Folder), I
> can see only 2 folders named as Deleted Items and Fld1.
> When I call Open Entry from OL Spy for Inbox/Outbox folder entry Id,
> then it fails.
>
> I don't know why MAPI is returning records for Inbox and Outbox which
> does not exists. Are these default folders of PST? If yes, is there a
> way to skip these folders. User does not want to see records for
> folders which is not visible in OL. If no, why GetHierarchyTable
> returning records which does not exist at all.
>
> Thanks in advance
> Sumit Khetrapal
date: Wed, 6 Aug 2008 09:29:57 -0700
author: Dmitry Streblechenko
Re: How to skip Default/Special Folders of PST
On Aug 6, 9:29 pm, "Dmitry Streblechenko" wrote:
> Are you usre you are opening te *exact* same PST? How do you open it?
>
> --
> Dmitry Streblechenko (MVP)http://www.dimastr.com/
> OutlookSpy - Outlook, CDO
> and MAPI Developer Tool
> -"Sumit Khetrapal" wrote in message
>
> news:806da2cf-42a8-4113-9069-58754b0e90a8@i24g2000prf.googlegroups.com...
>
> > Hi,
>
> > I am trying to read folder hierarchy of a PST (created using OL 2K3)
> > containing only 1 folder . I am using following set of code to get the
> > sub folders of Root folder (IPM_ROOT):
>
> > IMAPITable *hierarchy = NULL;
> > ULONG ulFlags = 0;
>
> > hr = m_lpMapiFolder-
> >>GetHierarchyTable(ulFlags, &hierarchy);
> > if (FAILED(hr))
> > {
> > cout << "GetHierarchyTable failed with
> > hr = " << hex << hr ;
> > break;
> > }
>
> > The above call is returning 4 records named as Inbox, Outbox, Deleted
> > Items and Fld1 (the one I exported).
> > When I open the PST using OL Spy (GetHierarchyTable on Root Folder), I
> > can see only 2 folders named as Deleted Items and Fld1.
> > When I call Open Entry from OL Spy for Inbox/Outbox folder entry Id,
> > then it fails.
>
> > I don't know why MAPI is returning records for Inbox and Outbox which
> > does not exists. Are these default folders of PST? If yes, is there a
> > way to skip these folders. User does not want to see records for
> > folders which is not visible in OL. If no, why GetHierarchyTable
> > returning records which does not exist at all.
>
> > Thanks in advance
> > Sumit Khetrapal
Hi Dmitry,
Thanks for the quick response.
Yes, I am opening a correct PST using MAPI by creating a temporary
profile for PST and then reading its contents.
Here is a sample coded which I am referring to:
HRESULT hr = S_OK; // Result from MAPI calls
LPPROFADMIN lpProfAdmin = NULL; // Profile Admin object
LPSERVICEADMIN lpSvcAdmin = NULL; // Service Admin object
LPMAPITABLE lpMsgSvcTable = NULL; // Table to hold services
LPSRowSet lpSvcRows = NULL; // Rowset to hold results of
table query
SRestriction sres; // Restriction structure
SPropValue SvcProps; // Property structure for
restriction
// This indicates columns we want returned from HrQueryAllRows
enum {iSvcName, iSvcUID, cptaSvc};
SizedSPropTagArray(cptaSvc,sptCols) = { cptaSvc, PR_SERVICE_NAME,
PR_SERVICE_UID };
// Get an IProfAdmin interface
if (FAILED(hr = MAPIAdminProfiles( 0, // Flags
&lpProfAdmin))) // Pointer to new IProfAdmin
{
break;
}
// Create a new profile
CHAR lpstrProfileName[50] = {0,};
wcstombs(lpstrProfileName, i_lpwstrProfileName,
wcslen(i_lpwstrProfileName) );
if (FAILED(hr = lpProfAdmin->CreateProfile(
(LPTSTR)lpstrProfileName, // Name of new profile
NULL, // Password for profile
NULL, // Handle to parent window
0))) // Flags
{
break;
}
// Get an IMsgServiceAdmin interface off of the IProfAdmin interface
if (FAILED(hr = lpProfAdmin->AdminServices(
i_lpwstrProfileName, // Profile that we want to modify
NULL, // Password for that profile
NULL, // Handle to parent window
MAPI_UNICODE, // Flags
&lpSvcAdmin))) // Pointer to new IMsgServiceAdmin
{
break;
}
// Create the new message service for Exchange
CHAR lpstrServiceName[20] = {0,};
wcstombs(lpstrServiceName, L"MSUPST MS", wcslen(L"MSUPST MS") );
CHAR lpstrServiceDisplayName[20] = {0,};
wcstombs(lpstrServiceDisplayName, L"MS U PST", wcslen(L"MS U PST") );
if (FAILED(hr = lpSvcAdmin-
>CreateMsgService((LPTSTR)lpstrServiceName, // Name of service
from MAPISVC.INF
(LPTSTR)lpstrServiceDisplayName,// Display name of service
NULL, // Handle to parent window
0))) // Flags
{
break;
}
// We now need to get the entry id for the new service
// This can be done by getting the message service table
// and getting the entry that corresponds to the new service.
if (FAILED(hr = lpSvcAdmin->GetMsgServiceTable(0, //
Flags
&lpMsgSvcTable))) // Pointer to table
{
break;
}
// Set up restriction to query table.
SvcProps.ulPropTag = PR_SERVICE_NAME;
SvcProps.Value.lpszW = L"MSUPST MS";
sres.rt = RES_CONTENT;
sres.res.resContent.ulFuzzyLevel = FL_FULLSTRING;//FL_SUBSTRING |
FL_IGNORECASE;
sres.res.resContent.ulPropTag = PR_SERVICE_NAME;
sres.res.resContent.lpProp = &SvcProps;
// Query the table to get the entry for the newly create message
service.
if (FAILED(hr = HrQueryAllRows(lpMsgSvcTable,
(LPSPropTagArray)&sptCols,
&sres,
NULL,
0,
&lpSvcRows)))
{
break;
}
if(lpSvcRows)
{
if(0 == lpSvcRows->cRows)
{
hr = E_FAIL;
break;
}
}
else
{
hr = E_FAIL;
break;
}
// Setup a SPropValue array for the properties you need to configure
SPropValue rgval[1]; // Property structure to hold
values we want to set
#define PST_EXTERN_PROPID_BASE_W (0x6700)
#define PR_PST_PATH_W PROP_TAG(PT_UNICODE,
PST_EXTERN_PROPID_BASE + 0)
#define PR_PST_PW_SZ_OLD_W PROP_TAG(PT_UNICODE,
PST_EXTERN_PROPID_BASE + 3)
#define PR_PST_PW_SZ_NEW_W PROP_TAG(PT_UNICODE,
PST_EXTERN_PROPID_BASE + 4)
// First, server name
ZeroMemory(&rgval[0], sizeof(SPropValue) );
rgval[0].ulPropTag = PR_PST_PATH_W;
rgval[0].Value.lpszW = i_lpwstrPSTPath;
// Configure the message service with the above properties
hr = lpSvcAdmin->ConfigureMsgService(
(LPMAPIUID)lpSvcRows->aRow-
>lpProps[iSvcUID].Value.bin.lpb, // Entry ID of service to configure
NULL, // Handle
to parent window
0, // Flags
1, // Number
of properties we are setting
rgval);
if (FAILED(hr)) //
Pointer to SPropValue array
{
break;
}
We provide the valid PST Path along with a profile name. If a profile
name already exists then we do send a new profile name. This check is
implemented before calling this code path.
Looking forward for your response.
date: Fri, 8 Aug 2008 00:16:28 -0700 (PDT)
author: Sumit Khetrapal
Re: How to skip Default/Special Folders of PST
Wait a sec, MAPI will always create Inbox and Sent Items folder on logon
whenever it touches a store set to be default and missing these folders.
When you add a new PST store without setting it as default, Deleted Items
folder is created.
--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
"Sumit Khetrapal" wrote in message
news:a819e433-8557-4d34-8e92-34b4aeb2719f@i20g2000prf.googlegroups.com...
> On Aug 6, 9:29 pm, "Dmitry Streblechenko" wrote:
>> Are you usre you are opening te *exact* same PST? How do you open it?
>>
>> --
>> Dmitry Streblechenko (MVP)http://www.dimastr.com/
>> OutlookSpy - Outlook, CDO
>> and MAPI Developer Tool
>> -"Sumit Khetrapal" wrote in message
>>
>> news:806da2cf-42a8-4113-9069-58754b0e90a8@i24g2000prf.googlegroups.com...
>>
>> > Hi,
>>
>> > I am trying to read folder hierarchy of a PST (created using OL 2K3)
>> > containing only 1 folder . I am using following set of code to get the
>> > sub folders of Root folder (IPM_ROOT):
>>
>> > IMAPITable *hierarchy = NULL;
>> > ULONG ulFlags = 0;
>>
>> > hr = m_lpMapiFolder-
>> >>GetHierarchyTable(ulFlags, &hierarchy);
>> > if (FAILED(hr))
>> > {
>> > cout << "GetHierarchyTable failed with
>> > hr = " << hex << hr ;
>> > break;
>> > }
>>
>> > The above call is returning 4 records named as Inbox, Outbox, Deleted
>> > Items and Fld1 (the one I exported).
>> > When I open the PST using OL Spy (GetHierarchyTable on Root Folder), I
>> > can see only 2 folders named as Deleted Items and Fld1.
>> > When I call Open Entry from OL Spy for Inbox/Outbox folder entry Id,
>> > then it fails.
>>
>> > I don't know why MAPI is returning records for Inbox and Outbox which
>> > does not exists. Are these default folders of PST? If yes, is there a
>> > way to skip these folders. User does not want to see records for
>> > folders which is not visible in OL. If no, why GetHierarchyTable
>> > returning records which does not exist at all.
>>
>> > Thanks in advance
>> > Sumit Khetrapal
>
> Hi Dmitry,
>
> Thanks for the quick response.
> Yes, I am opening a correct PST using MAPI by creating a temporary
> profile for PST and then reading its contents.
> Here is a sample coded which I am referring to:
>
>
> HRESULT hr = S_OK; // Result from MAPI calls
> LPPROFADMIN lpProfAdmin = NULL; // Profile Admin object
> LPSERVICEADMIN lpSvcAdmin = NULL; // Service Admin object
> LPMAPITABLE lpMsgSvcTable = NULL; // Table to hold services
> LPSRowSet lpSvcRows = NULL; // Rowset to hold results of
> table query
> SRestriction sres; // Restriction structure
> SPropValue SvcProps; // Property structure for
> restriction
>
> // This indicates columns we want returned from HrQueryAllRows
> enum {iSvcName, iSvcUID, cptaSvc};
> SizedSPropTagArray(cptaSvc,sptCols) = { cptaSvc, PR_SERVICE_NAME,
> PR_SERVICE_UID };
>
> // Get an IProfAdmin interface
> if (FAILED(hr = MAPIAdminProfiles( 0, // Flags
> &lpProfAdmin))) // Pointer to new IProfAdmin
> {
> break;
> }
>
> // Create a new profile
> CHAR lpstrProfileName[50] = {0,};
> wcstombs(lpstrProfileName, i_lpwstrProfileName,
> wcslen(i_lpwstrProfileName) );
> if (FAILED(hr = lpProfAdmin->CreateProfile(
> (LPTSTR)lpstrProfileName, // Name of new profile
> NULL, // Password for profile
> NULL, // Handle to parent window
> 0))) // Flags
> {
> break;
> }
>
>
> // Get an IMsgServiceAdmin interface off of the IProfAdmin interface
> if (FAILED(hr = lpProfAdmin->AdminServices(
> i_lpwstrProfileName, // Profile that we want to modify
> NULL, // Password for that profile
> NULL, // Handle to parent window
> MAPI_UNICODE, // Flags
> &lpSvcAdmin))) // Pointer to new IMsgServiceAdmin
> {
> break;
> }
>
> // Create the new message service for Exchange
> CHAR lpstrServiceName[20] = {0,};
> wcstombs(lpstrServiceName, L"MSUPST MS", wcslen(L"MSUPST MS") );
> CHAR lpstrServiceDisplayName[20] = {0,};
> wcstombs(lpstrServiceDisplayName, L"MS U PST", wcslen(L"MS U PST") );
>
> if (FAILED(hr = lpSvcAdmin-
>>CreateMsgService((LPTSTR)lpstrServiceName, // Name of service
> from MAPISVC.INF
> (LPTSTR)lpstrServiceDisplayName,// Display name of service
> NULL, // Handle to parent window
> 0))) // Flags
> {
> break;
> }
>
> // We now need to get the entry id for the new service
> // This can be done by getting the message service table
> // and getting the entry that corresponds to the new service.
>
> if (FAILED(hr = lpSvcAdmin->GetMsgServiceTable(0, //
> Flags
> &lpMsgSvcTable))) // Pointer to table
> {
> break;
> }
>
> // Set up restriction to query table.
>
> SvcProps.ulPropTag = PR_SERVICE_NAME;
> SvcProps.Value.lpszW = L"MSUPST MS";
>
> sres.rt = RES_CONTENT;
> sres.res.resContent.ulFuzzyLevel = FL_FULLSTRING;//FL_SUBSTRING |
> FL_IGNORECASE;
> sres.res.resContent.ulPropTag = PR_SERVICE_NAME;
> sres.res.resContent.lpProp = &SvcProps;
>
> // Query the table to get the entry for the newly create message
> service.
>
> if (FAILED(hr = HrQueryAllRows(lpMsgSvcTable,
> (LPSPropTagArray)&sptCols,
> &sres,
> NULL,
> 0,
> &lpSvcRows)))
> {
> break;
> }
>
> if(lpSvcRows)
> {
> if(0 == lpSvcRows->cRows)
> {
> hr = E_FAIL;
> break;
> }
> }
> else
> {
> hr = E_FAIL;
> break;
> }
> // Setup a SPropValue array for the properties you need to configure
>
> SPropValue rgval[1]; // Property structure to hold
> values we want to set
>
> #define PST_EXTERN_PROPID_BASE_W (0x6700)
> #define PR_PST_PATH_W PROP_TAG(PT_UNICODE,
> PST_EXTERN_PROPID_BASE + 0)
> #define PR_PST_PW_SZ_OLD_W PROP_TAG(PT_UNICODE,
> PST_EXTERN_PROPID_BASE + 3)
> #define PR_PST_PW_SZ_NEW_W PROP_TAG(PT_UNICODE,
> PST_EXTERN_PROPID_BASE + 4)
>
>
> // First, server name
> ZeroMemory(&rgval[0], sizeof(SPropValue) );
> rgval[0].ulPropTag = PR_PST_PATH_W;
> rgval[0].Value.lpszW = i_lpwstrPSTPath;
>
> // Configure the message service with the above properties
> hr = lpSvcAdmin->ConfigureMsgService(
> (LPMAPIUID)lpSvcRows->aRow-
>>lpProps[iSvcUID].Value.bin.lpb, // Entry ID of service to configure
>
> NULL, // Handle
> to parent window
> 0, // Flags
>
> 1, // Number
> of properties we are setting
> rgval);
>
> if (FAILED(hr)) //
> Pointer to SPropValue array
> {
> break;
> }
>
> We provide the valid PST Path along with a profile name. If a profile
> name already exists then we do send a new profile name. This check is
> implemented before calling this code path.
>
> Looking forward for your response.
date: Fri, 8 Aug 2008 09:58:41 -0700
author: Dmitry Streblechenko
Re: How to skip Default/Special Folders of PST
On Aug 8, 9:58 pm, "Dmitry Streblechenko" wrote:
> Wait a sec, MAPI will always create Inbox and Sent Items folder on logon
> whenever it touches a store set to be default and missing these folders.
> When you add a new PST store without setting it as default, Deleted Items
> folder is created.
>
> --
> Dmitry Streblechenko (MVP)http://www.dimastr.com/
> OutlookSpy - Outlook, CDO
> and MAPI Developer Tool
> -"Sumit Khetrapal" wrote in message
>
> news:a819e433-8557-4d34-8e92-34b4aeb2719f@i20g2000prf.googlegroups.com...
>
> > On Aug 6, 9:29 pm, "Dmitry Streblechenko" wrote:
> >> Are you usre you are opening te *exact* same PST? How do you open it?
>
> >> --
> >> Dmitry Streblechenko (MVP)http://www.dimastr.com/
> >> OutlookSpy - Outlook, CDO
> >> and MAPI Developer Tool
> >> -"Sumit Khetrapal" wrote in message
>
> >>news:806da2cf-42a8-4113-9069-58754b0e90a8@i24g2000prf.googlegroups.com...
>
> >> > Hi,
>
> >> > I am trying to read folder hierarchy of a PST (created using OL 2K3)
> >> > containing only 1 folder . I am using following set of code to get the
> >> > sub folders of Root folder (IPM_ROOT):
>
> >> > IMAPITable *hierarchy = NULL;
> >> > ULONG ulFlags = 0;
>
> >> > hr = m_lpMapiFolder-
> >> >>GetHierarchyTable(ulFlags, &hierarchy);
> >> > if (FAILED(hr))
> >> > {
> >> > cout << "GetHierarchyTable failed with
> >> > hr = " << hex << hr ;
> >> > break;
> >> > }
>
> >> > The above call is returning 4 records named as Inbox, Outbox, Deleted
> >> > Items and Fld1 (the one I exported).
> >> > When I open the PST using OL Spy (GetHierarchyTable on Root Folder), I
> >> > can see only 2 folders named as Deleted Items and Fld1.
> >> > When I call Open Entry from OL Spy for Inbox/Outbox folder entry Id,
> >> > then it fails.
>
> >> > I don't know why MAPI is returning records for Inbox and Outbox which
> >> > does not exists. Are these default folders of PST? If yes, is there a
> >> > way to skip these folders. User does not want to see records for
> >> > folders which is not visible in OL. If no, why GetHierarchyTable
> >> > returning records which does not exist at all.
>
> >> > Thanks in advance
> >> > Sumit Khetrapal
>
> > Hi Dmitry,
>
> > Thanks for the quick response.
> > Yes, I am opening a correct PST using MAPI by creating a temporary
> > profile for PST and then reading its contents.
> > Here is a sample coded which I am referring to:
>
> > HRESULT hr = S_OK; // Result from MAPI calls
> > LPPROFADMIN lpProfAdmin = NULL; // Profile Admin object
> > LPSERVICEADMIN lpSvcAdmin = NULL; // Service Admin object
> > LPMAPITABLE lpMsgSvcTable = NULL; // Table to hold services
> > LPSRowSet lpSvcRows = NULL; // Rowset to hold results of
> > table query
> > SRestriction sres; // Restriction structure
> > SPropValue SvcProps; // Property structure for
> > restriction
>
> > // This indicates columns we want returned from HrQueryAllRows
> > enum {iSvcName, iSvcUID, cptaSvc};
> > SizedSPropTagArray(cptaSvc,sptCols) = { cptaSvc, PR_SERVICE_NAME,
> > PR_SERVICE_UID };
>
> > // Get an IProfAdmin interface
> > if (FAILED(hr = MAPIAdminProfiles( 0, // Flags
> > &lpProfAdmin))) // Pointer to new IProfAdmin
> > {
> > break;
> > }
>
> > // Create a new profile
> > CHAR lpstrProfileName[50] = {0,};
> > wcstombs(lpstrProfileName, i_lpwstrProfileName,
> > wcslen(i_lpwstrProfileName) );
> > if (FAILED(hr = lpProfAdmin->CreateProfile(
> > (LPTSTR)lpstrProfileName, // Name of new profile
> > NULL, // Password for profile
> > NULL, // Handle to parent window
> > 0))) // Flags
> > {
> > break;
> > }
>
> > // Get an IMsgServiceAdmin interface off of the IProfAdmin interface
> > if (FAILED(hr = lpProfAdmin->AdminServices(
> > i_lpwstrProfileName, // Profile that we want to modify
> > NULL, // Password for that profile
> > NULL, // Handle to parent window
> > MAPI_UNICODE, // Flags
> > &lpSvcAdmin))) // Pointer to new IMsgServiceAdmin
> > {
> > break;
> > }
>
> > // Create the new message service for Exchange
> > CHAR lpstrServiceName[20] = {0,};
> > wcstombs(lpstrServiceName, L"MSUPST MS", wcslen(L"MSUPST MS") );
> > CHAR lpstrServiceDisplayName[20] = {0,};
> > wcstombs(lpstrServiceDisplayName, L"MS U PST", wcslen(L"MS U PST") );
>
> > if (FAILED(hr = lpSvcAdmin-
> >>CreateMsgService((LPTSTR)lpstrServiceName, // Name of service
> > from MAPISVC.INF
> > (LPTSTR)lpstrServiceDisplayName,// Display name of service
> > NULL, // Handle to parent window
> > 0))) // Flags
> > {
> > break;
> > }
>
> > // We now need to get the entry id for the new service
> > // This can be done by getting the message service table
> > // and getting the entry that corresponds to the new service.
>
> > if (FAILED(hr = lpSvcAdmin->GetMsgServiceTable(0, //
> > Flags
> > &lpMsgSvcTable))) // Pointer to table
> > {
> > break;
> > }
>
> > // Set up restriction to query table.
>
> > SvcProps.ulPropTag = PR_SERVICE_NAME;
> > SvcProps.Value.lpszW = L"MSUPST MS";
>
> > sres.rt = RES_CONTENT;
> > sres.res.resContent.ulFuzzyLevel = FL_FULLSTRING;//FL_SUBSTRING |
> > FL_IGNORECASE;
> > sres.res.resContent.ulPropTag = PR_SERVICE_NAME;
> > sres.res.resContent.lpProp = &SvcProps;
>
> > // Query the table to get the entry for the newly create message
> > service.
>
> > if (FAILED(hr = HrQueryAllRows(lpMsgSvcTable,
> > (LPSPropTagArray)&sptCols,
> > &sres,
> > NULL,
> > 0,
> > &lpSvcRows)))
> > {
> > break;
> > }
>
> > if(lpSvcRows)
> > {
> > if(0 == lpSvcRows->cRows)
> > {
> > hr = E_FAIL;
> > break;
> > }
> > }
> > else
> > {
> > hr = E_FAIL;
> > break;
> > }
> > // Setup a SPropValue array for the properties you need to configure
>
> > SPropValue rgval[1]; // Property structure to hold
> > values we want to set
>
> > #define PST_EXTERN_PROPID_BASE_W (0x6700)
> > #define PR_PST_PATH_W PROP_TAG(PT_UNICODE,
> > PST_EXTERN_PROPID_BASE + 0)
> > #define PR_PST_PW_SZ_OLD_W PROP_TAG(PT_UNICODE,
> > PST_EXTERN_PROPID_BASE + 3)
> > #define PR_PST_PW_SZ_NEW_W PROP_TAG(PT_UNICODE,
> > PST_EXTERN_PROPID_BASE + 4)
>
> > // First, server name
> > ZeroMemory(&rgval[0], sizeof(SPropValue) );
> > rgval[0].ulPropTag = PR_PST_PATH_W;
> > rgval[0].Value.lpszW = i_lpwstrPSTPath;
>
> > // Configure the message service with the above properties
> > hr = lpSvcAdmin->ConfigureMsgService(
> > (LPMAPIUID)lpSvcRows->aRow-
> >>lpProps[iSvcUID].Value.bin.lpb, // Entry ID of service to configure
>
> > NULL, // Handle
> > to parent window
> > 0, // Flags
>
> > 1, // Number
> > of properties we are setting
> > rgval);
>
> > if (FAILED(hr)) //
> > Pointer to SPropValue array
> > {
> > break;
> > }
>
> > We provide the valid PST Path along with a profile name. If a profile
> > name already exists then we do send a new profile name. This check is
> > implemented before calling this code path.
>
> > Looking forward for your response.
Hi Dmitry,
Yes, you are correct, I was opening the DefaultMSGStore using
HrMAPIFindDefaultMsgStore API.
I tried following code path to open the message store but still find
the default folders
hr = HrQueryAllRows(lpMsgStoreTable,
(LPSPropTagArray)&sProps, NULL, NULL, 0, &lpRowSet);
if ( FAILED(hr) )
{
break;
}
if(NULL == lpRowSet || 0 == lpRowSet->cRows)
{
hr = E_FAIL;
break;
}
cbEid = lpRowSet->aRow[0].lpProps[0].Value.bin.cb;
MAPIAllocateBuffer( cbEid, (LPVOID *) &lpEid);
memcpy( lpEid, lpRowSet->aRow[0].lpProps[0].Value.bin.lpb, cbEid);
pFreeProws(lpRowSet);
const ULONG ulMDBflags = MDB_NO_DIALOG | MDB_WRITE|
MDB_TEMPORARY;
// Open the store based on entry id
hr = m_lpMapiSession->OpenMsgStore(0, // window handle
cbEid, // # of bytes in entry ID
lpEid, // pointer to entry ID
NULL, // interface ID pointer
ulMDBflags, // flags
&m_lpmdbPrivateStore); // output ptr to store
Can you please let me know how should I proceed to open the message
store so that MAPI will not create these default folders (Inbox and
Outbox).
Thanks in advance
Sumit Khetrapal
date: Sat, 9 Aug 2008 01:28:28 -0700 (PDT)
author: Sumit Khetrapal
Re: How to skip Default/Special Folders of PST
If it is the only store in the profile, it will be made default.
You can only make this work if you open the PST store as a secondary store
in the profile.
--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
"Sumit Khetrapal" wrote in message
news:b8c79bf6-966e-439b-bf09-8def979cbaa9@l33g2000pri.googlegroups.com...
> On Aug 8, 9:58 pm, "Dmitry Streblechenko" wrote:
>> Wait a sec, MAPI will always create Inbox and Sent Items folder on logon
>> whenever it touches a store set to be default and missing these folders.
>> When you add a new PST store without setting it as default, Deleted Items
>> folder is created.
>>
>> --
>> Dmitry Streblechenko (MVP)http://www.dimastr.com/
>> OutlookSpy - Outlook, CDO
>> and MAPI Developer Tool
>> -"Sumit Khetrapal" wrote in message
>>
>> news:a819e433-8557-4d34-8e92-34b4aeb2719f@i20g2000prf.googlegroups.com...
>>
>> > On Aug 6, 9:29 pm, "Dmitry Streblechenko" wrote:
>> >> Are you usre you are opening te *exact* same PST? How do you open it?
>>
>> >> --
>> >> Dmitry Streblechenko (MVP)http://www.dimastr.com/
>> >> OutlookSpy - Outlook, CDO
>> >> and MAPI Developer Tool
>> >> -"Sumit Khetrapal" wrote in message
>>
>> >>news:806da2cf-42a8-4113-9069-58754b0e90a8@i24g2000prf.googlegroups.com...
>>
>> >> > Hi,
>>
>> >> > I am trying to read folder hierarchy of a PST (created using OL 2K3)
>> >> > containing only 1 folder . I am using following set of code to get
>> >> > the
>> >> > sub folders of Root folder (IPM_ROOT):
>>
>> >> > IMAPITable *hierarchy = NULL;
>> >> > ULONG ulFlags = 0;
>>
>> >> > hr = m_lpMapiFolder-
>> >> >>GetHierarchyTable(ulFlags, &hierarchy);
>> >> > if (FAILED(hr))
>> >> > {
>> >> > cout << "GetHierarchyTable failed
>> >> > with
>> >> > hr = " << hex << hr ;
>> >> > break;
>> >> > }
>>
>> >> > The above call is returning 4 records named as Inbox, Outbox,
>> >> > Deleted
>> >> > Items and Fld1 (the one I exported).
>> >> > When I open the PST using OL Spy (GetHierarchyTable on Root Folder),
>> >> > I
>> >> > can see only 2 folders named as Deleted Items and Fld1.
>> >> > When I call Open Entry from OL Spy for Inbox/Outbox folder entry Id,
>> >> > then it fails.
>>
>> >> > I don't know why MAPI is returning records for Inbox and Outbox
>> >> > which
>> >> > does not exists. Are these default folders of PST? If yes, is there
>> >> > a
>> >> > way to skip these folders. User does not want to see records for
>> >> > folders which is not visible in OL. If no, why GetHierarchyTable
>> >> > returning records which does not exist at all.
>>
>> >> > Thanks in advance
>> >> > Sumit Khetrapal
>>
>> > Hi Dmitry,
>>
>> > Thanks for the quick response.
>> > Yes, I am opening a correct PST using MAPI by creating a temporary
>> > profile for PST and then reading its contents.
>> > Here is a sample coded which I am referring to:
>>
>> > HRESULT hr = S_OK; // Result from MAPI calls
>> > LPPROFADMIN lpProfAdmin = NULL; // Profile Admin object
>> > LPSERVICEADMIN lpSvcAdmin = NULL; // Service Admin object
>> > LPMAPITABLE lpMsgSvcTable = NULL; // Table to hold services
>> > LPSRowSet lpSvcRows = NULL; // Rowset to hold results of
>> > table query
>> > SRestriction sres; // Restriction structure
>> > SPropValue SvcProps; // Property structure for
>> > restriction
>>
>> > // This indicates columns we want returned from HrQueryAllRows
>> > enum {iSvcName, iSvcUID, cptaSvc};
>> > SizedSPropTagArray(cptaSvc,sptCols) = { cptaSvc, PR_SERVICE_NAME,
>> > PR_SERVICE_UID };
>>
>> > // Get an IProfAdmin interface
>> > if (FAILED(hr = MAPIAdminProfiles( 0, // Flags
>> > &lpProfAdmin))) // Pointer to new IProfAdmin
>> > {
>> > break;
>> > }
>>
>> > // Create a new profile
>> > CHAR lpstrProfileName[50] = {0,};
>> > wcstombs(lpstrProfileName, i_lpwstrProfileName,
>> > wcslen(i_lpwstrProfileName) );
>> > if (FAILED(hr = lpProfAdmin->CreateProfile(
>> > (LPTSTR)lpstrProfileName, // Name of new profile
>> > NULL, // Password for profile
>> > NULL, // Handle to parent window
>> > 0))) // Flags
>> > {
>> > break;
>> > }
>>
>> > // Get an IMsgServiceAdmin interface off of the IProfAdmin interface
>> > if (FAILED(hr = lpProfAdmin->AdminServices(
>> > i_lpwstrProfileName, // Profile that we want to modify
>> > NULL, // Password for that profile
>> > NULL, // Handle to parent window
>> > MAPI_UNICODE, // Flags
>> > &lpSvcAdmin))) // Pointer to new IMsgServiceAdmin
>> > {
>> > break;
>> > }
>>
>> > // Create the new message service for Exchange
>> > CHAR lpstrServiceName[20] = {0,};
>> > wcstombs(lpstrServiceName, L"MSUPST MS", wcslen(L"MSUPST MS") );
>> > CHAR lpstrServiceDisplayName[20] = {0,};
>> > wcstombs(lpstrServiceDisplayName, L"MS U PST", wcslen(L"MS U PST") );
>>
>> > if (FAILED(hr = lpSvcAdmin-
>> >>CreateMsgService((LPTSTR)lpstrServiceName, // Name of service
>> > from MAPISVC.INF
>> > (LPTSTR)lpstrServiceDisplayName,// Display name of service
>> > NULL, // Handle to parent window
>> > 0))) // Flags
>> > {
>> > break;
>> > }
>>
>> > // We now need to get the entry id for the new service
>> > // This can be done by getting the message service table
>> > // and getting the entry that corresponds to the new service.
>>
>> > if (FAILED(hr = lpSvcAdmin->GetMsgServiceTable(0, //
>> > Flags
>> > &lpMsgSvcTable))) // Pointer to table
>> > {
>> > break;
>> > }
>>
>> > // Set up restriction to query table.
>>
>> > SvcProps.ulPropTag = PR_SERVICE_NAME;
>> > SvcProps.Value.lpszW = L"MSUPST MS";
>>
>> > sres.rt = RES_CONTENT;
>> > sres.res.resContent.ulFuzzyLevel = FL_FULLSTRING;//FL_SUBSTRING |
>> > FL_IGNORECASE;
>> > sres.res.resContent.ulPropTag = PR_SERVICE_NAME;
>> > sres.res.resContent.lpProp = &SvcProps;
>>
>> > // Query the table to get the entry for the newly create message
>> > service.
>>
>> > if (FAILED(hr = HrQueryAllRows(lpMsgSvcTable,
>> > (LPSPropTagArray)&sptCols,
>> > &sres,
>> > NULL,
>> > 0,
>> > &lpSvcRows)))
>> > {
>> > break;
>> > }
>>
>> > if(lpSvcRows)
>> > {
>> > if(0 == lpSvcRows->cRows)
>> > {
>> > hr = E_FAIL;
>> > break;
>> > }
>> > }
>> > else
>> > {
>> > hr = E_FAIL;
>> > break;
>> > }
>> > // Setup a SPropValue array for the properties you need to configure
>>
>> > SPropValue rgval[1]; // Property structure to hold
>> > values we want to set
>>
>> > #define PST_EXTERN_PROPID_BASE_W (0x6700)
>> > #define PR_PST_PATH_W PROP_TAG(PT_UNICODE,
>> > PST_EXTERN_PROPID_BASE + 0)
>> > #define PR_PST_PW_SZ_OLD_W PROP_TAG(PT_UNICODE,
>> > PST_EXTERN_PROPID_BASE + 3)
>> > #define PR_PST_PW_SZ_NEW_W PROP_TAG(PT_UNICODE,
>> > PST_EXTERN_PROPID_BASE + 4)
>>
>> > // First, server name
>> > ZeroMemory(&rgval[0], sizeof(SPropValue) );
>> > rgval[0].ulPropTag = PR_PST_PATH_W;
>> > rgval[0].Value.lpszW = i_lpwstrPSTPath;
>>
>> > // Configure the message service with the above properties
>> > hr = lpSvcAdmin->ConfigureMsgService(
>> > (LPMAPIUID)lpSvcRows->aRow-
>> >>lpProps[iSvcUID].Value.bin.lpb, // Entry ID of service to configure
>>
>> > NULL, // Handle
>> > to parent window
>> > 0, // Flags
>>
>> > 1, // Number
>> > of properties we are setting
>> > rgval);
>>
>> > if (FAILED(hr)) //
>> > Pointer to SPropValue array
>> > {
>> > break;
>> > }
>>
>> > We provide the valid PST Path along with a profile name. If a profile
>> > name already exists then we do send a new profile name. This check is
>> > implemented before calling this code path.
>>
>> > Looking forward for your response.
>
> Hi Dmitry,
>
> Yes, you are correct, I was opening the DefaultMSGStore using
> HrMAPIFindDefaultMsgStore API.
> I tried following code path to open the message store but still find
> the default folders
>
> hr = HrQueryAllRows(lpMsgStoreTable,
> (LPSPropTagArray)&sProps, NULL, NULL, 0, &lpRowSet);
> if ( FAILED(hr) )
> {
> break;
> }
>
> if(NULL == lpRowSet || 0 == lpRowSet->cRows)
> {
> hr = E_FAIL;
> break;
> }
> cbEid = lpRowSet->aRow[0].lpProps[0].Value.bin.cb;
> MAPIAllocateBuffer( cbEid, (LPVOID *) &lpEid);
> memcpy( lpEid, lpRowSet->aRow[0].lpProps[0].Value.bin.lpb, cbEid);
>
> pFreeProws(lpRowSet);
>
> const ULONG ulMDBflags = MDB_NO_DIALOG | MDB_WRITE|
> MDB_TEMPORARY;
> // Open the store based on entry id
> hr = m_lpMapiSession->OpenMsgStore(0, // window handle
> cbEid, // # of bytes in entry ID
> lpEid, // pointer to entry ID
> NULL, // interface ID pointer
> ulMDBflags, // flags
> &m_lpmdbPrivateStore); // output ptr to store
>
> Can you please let me know how should I proceed to open the message
> store so that MAPI will not create these default folders (Inbox and
> Outbox).
>
> Thanks in advance
> Sumit Khetrapal
date: Sun, 10 Aug 2008 08:58:39 -0700
author: Dmitry Streblechenko
|
|