Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Creating 2003 .PST file Programmatically

45 views
Skip to first unread message

Sandeep

unread,
Jun 23, 2005, 12:35:03 PM6/23/05
to
I am trying to create a 2003 type PST file (With the increased file size
over the earlier type of PST files). I have outlined the steps I have done
so far and the problems I have encountered.

From the MAPISVC.inf file which is found on all client machines,
Here are the services available

[Services]
MSPST MS=Outlook 97-2002 Personal Folders File (.pst)
MSUPST MS=Office Outlook Personal Folders File (.pst)


I tried using the IMsgServiceAdmin::CreateMsgService using “MSUPST MS” as
the type of message service. And then IMsgServiceAdmin::ConfigureMsgService
setting Properties like PR_DISPLAY_NAME, PR_PST_PATH, PR_PST_ENCRYPTION

(IMsgServiceAdmin Obtained from IProfAdmin)

What i end up with is still a Outlook 97-2002 Personal Folders File (.pst)
file.

Any Suggestions.


Dmitry Streblechenko

unread,
Jun 23, 2005, 1:27:07 PM6/23/05
to
What makes you think you end up with an old (MSPST MS) pst file? Note that
PR_MDB_PROVIDER is the same for both.

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

"Sandeep" <San...@discussions.microsoft.com> wrote in message
news:B20F01C1-0CD5-44D2...@microsoft.com...

Sandeep

unread,
Jun 23, 2005, 1:57:02 PM6/23/05
to
When i open outlook and look ant the personal folder (Just Created)
properties (Advanced) there is a format: which says it is Outlook 97-2002
Personal Folders File (.pst). Also none of the methods i have used give any
error codes.

Dmitry Streblechenko

unread,
Jun 23, 2005, 2:18:00 PM6/23/05
to
Outlook gets confused about the format all the time, especially if you have
multiple PST files.
When you look at the PR_STORE_SUPPORT_MASK property for IMsgStore, do you
see the STORE_UNICODE_OK bit?

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

"Sandeep" <San...@discussions.microsoft.com> wrote in message

news:68035021-CD89-43AB...@microsoft.com...

Sandeep

unread,
Jun 23, 2005, 3:50:05 PM6/23/05
to
Dmitry thanks for your quick responses. I dont see the STORE_UNICODE_OK bit
set infact it has the bit STORE_ANSI_OK bit set. I understand
PR_STORE_SUPPORT_MASK is a property that is generated and cannot be modified.

Dmitry Streblechenko

unread,
Jun 23, 2005, 6:07:58 PM6/23/05
to
Ok, what is your code? Did you make sure the PST file does not exist yet?

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

"Sandeep" <San...@discussions.microsoft.com> wrote in message

news:70E3BCF1-6BCE-4D85...@microsoft.com...

Sandeep

unread,
Jun 24, 2005, 3:01:03 PM6/24/05
to
The File does not exist before i try to create it. I have this Functionality
wrapped around a COM Object the relevalt pieces i have reproduced here. I
have also tried deleteing all my other personal folders before creating a new
one with the same result which is i successfuly create a PST file but of the
wrong format.

RESULT CProfHelper::FinalConstruct()
{
LONG lRet;
DWORD dwRet;
HRESULT hr;

m_bMAPI = FALSE;

hr = MAPIInitialize(NULL);
if (S_OK == hr)
{
hr = MAPIAdminProfiles(0, &m_pProfAdmin);

}
return hr;
}

Parameters = "Test Profile", "MSUPST MS", "My PST File"

STDMETHODIMP CProfHelper::AddMessageService(BSTR ProfileName,
BSTR MsgServiceName,
BSTR MsgServiceDispName,
LONG* lRet)
{
CComPtr<IMsgServiceAdmin> pMsgSvcAdmin;
_bstr_t bstrPN;
_bstr_t bstrSN;
_bstr_t bstrDN;
ULONG ulFlags;
HRESULT hr;

if( IsBadWritePtr(lRet, sizeof(LONG)) )
{
hr = E_INVALIDARG;
}
else
{
ulFlags = 0;
ulFlags |= fMapiUnicode;

bstrPN = ProfileName;
hr = m_pProfAdmin->AdminServices((TCHAR*)bstrPN, NULL, NULL, ulFlags,
&pMsgSvcAdmin);
if(S_OK == hr)
{
bstrSN = MsgServiceName;
bstrDN = MsgServiceDispName;
hr = pMsgSvcAdmin->CreateMsgService((TCHAR*)bstrSN, (TCHAR*)bstrDN, NULL,
ulFlags);
}
}

*lRet = ResultCode(hr);
if (*lRet)
{
hr = RaiseException(*lRet);
}

return hr;
}

Parameters = "Test Profile", "MSUPST MS", "My PST File", "C:\TestMy.pst",
"Comment", NULL, NULL, FALSE, 0x80000000, 0


STDMETHODIMP CProfHelper::ConfigMSPSTMS(BSTR ProfileName,
BSTR MsgServiceName,
BSTR MsgServiceDisplayName,
BSTR Path,
BSTR Comment,
BSTR Password,
BSTR NewPassword,
VARIANT_BOOL RememberPwd,
LONG Encryption,
ULONG WindowHandle,
LONG* lRet)
{
CComPtr<IMsgServiceAdmin> pMsgSvcAdmin;
CComPtr<IMAPITable> pMsgSvcTable;
_bstr_t bstrPN;
_bstr_t bstrDN;
_bstr_t bstrPT;
_bstr_t bstrC;
_bstr_t bstrOP;
_bstr_t bstrNP;
LPSRowSet pRows;
ULONG ulFlags;
UINT idx;
SPropValue spv[7];
HRESULT hr;

if( IsBadWritePtr(lRet, sizeof(LONG)) )
{
hr = E_INVALIDARG;
}
else
{
ulFlags = 0;
ulFlags |= fMapiUnicode;

bstrPN = ProfileName;
hr = m_pProfAdmin->AdminServices((TCHAR*)bstrPN, NULL, NULL, ulFlags,
&pMsgSvcAdmin);
if (S_OK == hr)
{
hr = pMsgSvcAdmin->GetMsgServiceTable(ulFlags, &pMsgSvcTable);
if (S_OK == hr)
{
pRows = NULL;
hr = GetMAPITableRowSet(pMsgSvcTable, MsgServiceName, PR_SERVICE_NAME,
&pRows);
if (S_OK == hr)
{
if (WindowHandle)
ulFlags |= SERVICE_UI_ALWAYS;

for (int i=0; i < 7; i++)
ZeroMemory(&spv[i], sizeof(SPropValue));

bstrDN = MsgServiceDisplayName;
idx = 0;
spv[idx].ulPropTag = PR_DISPLAY_NAME;
if (fMapiUnicode)
spv[idx].Value.lpszW = (wchar_t*)bstrDN;
else
spv[idx].Value.lpszA = (char*)bstrDN;

bstrPT = Path;
idx++;
spv[idx].ulPropTag = PR_PST_PATH;
if (fMapiUnicode)
spv[idx].Value.lpszW = (wchar_t*)bstrPT;
else
spv[idx].Value.lpszA = (char*)bstrPT;

STORE_UNICODE_OK


bstrC = Comment;
idx++;
spv[idx].ulPropTag = PR_COMMENT;
if (fMapiUnicode)
spv[idx].Value.lpszW = (wchar_t*)bstrC;
else
spv[idx].Value.lpszA = (char*)bstrC;

bstrOP = Password;
idx++;
spv[idx].ulPropTag = PR_PST_PW_SZ_OLD;
if (fMapiUnicode)
spv[idx].Value.lpszW = (wchar_t*)bstrOP;
else
spv[idx].Value.lpszA = (char*)bstrOP;

bstrNP = NewPassword;
idx++;
spv[idx].ulPropTag = PR_PST_PW_SZ_NEW;
if (fMapiUnicode)
spv[idx].Value.lpszW = (wchar_t*)bstrNP;
else
spv[idx].Value.lpszA = (char*)bstrNP;

idx++;
spv[idx].ulPropTag = PR_PST_REMEMBER_PW;
spv[idx].Value.b = RememberPwd;

idx++;
spv[idx].ulPropTag = PR_PST_ENCRYPTION;
spv[idx].Value.l = Encryption;

idx++;

PR_STORE_SUPPORT_MASK

hr =
pMsgSvcAdmin->ConfigureMsgService((LPMAPIUID)(pRows->aRow->lpProps->Value.bin.lpb),
WindowHandle, ulFlags, idx, spv);

FreeProws(pRows);
}
}
}
}

*lRet = ResultCode(hr);
if (*lRet)
{
hr = RaiseException(*lRet);
}

return hr;

Dmitry Streblechenko

unread,
Jun 25, 2005, 7:56:28 PM6/25/05
to
Why do you specify the PR_STORE_SUPPORT_MASK property?
Try to specify only two properties: PR_PST_PATH and PR_DISPLAY_NAME

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

"Sandeep" <San...@discussions.microsoft.com> wrote in message

news:99246928-2624-4C08...@microsoft.com...

Sandeep

unread,
Jun 27, 2005, 11:47:02 AM6/27/05
to
That was an error pasting it in the window. I dont use the
PR_STORE_SUPPORT_MASK property. Only the PR_PST_PATH and PR_DISPLAY_NAME,
PR_COMMENT and the encryption which is set to no encryption.

Dmitry Streblechenko

unread,
Jun 28, 2005, 5:25:57 PM6/28/05
to
Hmmm...I don't know...

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

"Sandeep" <San...@discussions.microsoft.com> wrote in message

news:3BB07124-11E0-45B3...@microsoft.com...

Anay Kulkarni

unread,
Jan 6, 2010, 10:16:04 AM1/6/10
to
Hi Sandeep (and Dmitry),
I know it's long since you've written this thing. But i wanna ask you one
thing. You are calling GetMAPITableRowSet function to get the MAPIUID of the
service you just created. But there can be many services in the current
profile with PR_SERVICE_NAME as "MSUPST MS". So you might get more than one
SRow s in the SRowSet pointed to by pRows. So you should also write code to
check which one is created by you.. otherwise you'll end up configuring the
first one that is there in the pRows.

OR

You should always delete all PSTs in your Profile for this code to work
properly.

url:http://www.ureader.com/msg/1475319.aspx

Dmitry Streblechenko

unread,
Jan 6, 2010, 11:49:06 AM1/6/10
to
Take a snapshot of the services before you add a new one, then take another
snapshot after adding the new service. The one not in the first set is your
newly added service.

--

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

-
"Anay Kulkarni" <bi...@windows.com> wrote in message news:...
> Message-ID: <981d55ddd11f46d3...@newspe.com>
> X-Mailer: http://www.umailcampaign.com, ip log:121.242.40.21
> Newsgroups: microsoft.public.win32.programmer.messaging
> NNTP-Posting-Host: 22.bb.5446.static.theplanet.com 70.84.187.34
> Path: TK2MSFTNGP01.phx.gbl!TK2MSFTNGP04.phx.gbl!newspe.com
> Lines: 1
> Xref: TK2MSFTNGP01.phx.gbl
> microsoft.public.win32.programmer.messaging:34287

Kulkarni@discussions.microsoft.com Anay Kulkarni

unread,
Jan 10, 2010, 5:00:01 AM1/10/10
to
Thanks Dmitry..

We greatly appreciate your knowledge and the will to share it so freely with
others..

"Dmitry Streblechenko" wrote:

> .
>

0 new messages