Re: What is next step to extracting PST contact items



And there's the problem. IMO mode doesn't really support Extended MAPI. A
lot of stuff kinda works, but even more fails spectacularly. You need to run
in Corporate Workgroup mode to get Extended MAPI support.

We cut IMO mode in Outlook 2002.

"Angus Comber" <anguscomber@xxxxxxxxxxxxxxx> wrote in message
news:usqR$ISZGHA.3480@xxxxxxxxxxxxxxxxxxxxxxx
Outlook 2000 - Help About says:

Outlook 2000 SR-1 (9.0.0.3821)
Internet Mail Only



"Dmitry Streblechenko" <dmitry@xxxxxxxxxxx> wrote in message
news:#J2V7gMZGHA.5004@xxxxxxxxxxxxxxxxxxxxxxx
What is your version of Outlook?

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

"Angus Comber" <anguscomber@xxxxxxxxxxxxxxx> wrote in message
news:e2v8CMMZGHA.3400@xxxxxxxxxxxxxxxxxxxxxxx
I don't understand what you mean when you say 'Can I open all PST store?

When I MAPILogonEx with MAPI_LOGON_UI I see two profiles to login to.
One
just says 'Microsoft Outlook'. The other says 'Microsoft Outlook
Internet
Settings' -

If I choose 'Microsoft Outlook Internet Settings' as profile to logon
to
I
get 0x8004010f and: An unexpected error has occurred. MAPI was unable
to
load the information service PSTPRX.DLL. Be sure the service is
correctly
installed and configured.

If I choose 'Microsoft Outlook' I get: An unexpected error has
occurred.
MAPI was unable to load the information service mspst.dll. Be sure the
service is correctly installed and configured.

Help me.......

When I run Outlook (ie without code!) I am not prompted to login - just
goes
into Outlook.

Angus




"Dmitry Streblechenko" <dmitry@xxxxxxxxxxx> wrote in message
news:#UWYApLZGHA.3328@xxxxxxxxxxxxxxxxxxxxxxx
The error is MAPI_E_NOT_FOUND.
Can you open *all* PST store when you log to that profile with
Outlook?
Did you try to add MAPI_EXPLICIT_PROFILE when calling MAPILogonEx to
make
sure you log to the expected profile?

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

"Angus Comber" <anguscomber@xxxxxxxxxxxxxxx> wrote in message
news:u6mBneLZGHA.4884@xxxxxxxxxxxxxxxxxxxxxxx
Been playing around and now using this code:

But OpenMsgStore returns 0x8004010f

Here is slightly updated code:

const int ieidMax = 28;

static const SizedSPropTagArray(ieidMax, ptaEid)=
{
ieidMax,
{
PR_ENTRYID, // Non Text
PR_DISPLAY_NAME, // Name tab, Display field
PR_EMAIL_ADDRESS, // Name tab, Email addresses
PR_DISPLAY_NAME_PREFIX, // Name tab, Title
PR_GIVEN_NAME, // Name Tab, First (name) field
PR_MIDDLE_NAME, // Name tab, Middle (ie like initials)
PR_SURNAME, // Name tab, Surname
PR_NICKNAME, // Name tab, Nickname
PR_HOME_ADDRESS_STREET, // Home tab, Street Address (8)
PR_HOME_ADDRESS_CITY, // Home tab, City (9)
PR_HOME_ADDRESS_STATE_OR_PROVINCE, // Home tab, State/Province (10)
PR_HOME_ADDRESS_POSTAL_CODE, // Home tab, Zipcode (11)
PR_HOME_ADDRESS_COUNTRY, // Home tab, Country/Region (12)
PR_HOME_TELEPHONE_NUMBER, // Home tab, Phone (13)
PR_PERSONAL_HOME_PAGE, // Home tab, Web page (14)
PR_HOME_FAX_NUMBER, // Home tab, Fax (15)
PR_MOBILE_TELEPHONE_NUMBER, // Home tab, Mobile (16)
PR_COMPANY_NAME, // Business tab, Company (17)
PR_BUSINESS_ADDRESS_STREET, // Business tab, Street Address (18)
PR_BUSINESS_ADDRESS_CITY, // Business tab, City (19)
PR_BUSINESS_ADDRESS_STATE_OR_PROVINCE, // Business tab,
State/Province
(20)
PR_BUSINESS_ADDRESS_POSTAL_CODE, // Business tab, Zip Code (21)
PR_BUSINESS_ADDRESS_COUNTRY, // Business tab, Country (22)
PR_BUSINESS_TELEPHONE_NUMBER, // Business tab, Phone (23)
PR_BUSINESS_HOME_PAGE, // Business tab, Web Page (24)
PR_BUSINESS_FAX_NUMBER, // Business tab, Fax (25)
PR_TITLE, // Business tab, Job Title (26)
PR_COMMENT, // Other tab, Notes (27)
}
};

if (MAPIInitialize(0) == S_OK)
printf("MAPI initialised\n");
char szError[256];
ULONG ulFlags = 0;
ulFlags = ulFlags | MAPI_LOGON_UI | MAPI_NO_MAIL | MAPI_EXTENDED;
LPMAPISESSION pSession = NULL;
HRESULT hr = MAPILogonEx(0, 0, 0, ulFlags, &pSession);
SCODE sc = S_OK;
LPMAPITABLE pMAPITable = NULL;
hr = pSession->GetMsgStoresTable(0, &pMAPITable); // only flag seems
to
be
MAPI_UNICODE
// Set columns we want
hr = pMAPITable->SetColumns((LPSPropTagArray)&ptaEid, 0 );
SRowSet* pSRowSet = NULL;
hr = pMAPITable->QueryRows(5, 0, &pSRowSet);
IMsgStore* pStore = NULL;
hr = pSession->OpenMsgStore(0,
pSRowSet->aRow[0].lpProps[0].Value.bin.cb,
(ENTRYID *)pSRowSet->aRow[0].lpProps[0].Value.bin.lpb,
NULL, 0, &pStore);

MAPIERROR* pMapiError = NULL;
pSession->GetLastError(hr, 0, &pMapiError);

error description is now
An unexpected error has occurred. MAPI was unable to load the
information
service PSTPRX.DLL. Be sure the service is correctly installed and
configured.

And interestingly I think things worked better when I selected
Microsoft
Outlook (rather than eg Outlook Express) as default email in IE
Tools...
Internet Options... Programs.

The struct was something I re-used from some code which extracts
contacts
from the Windows Address Book (which works). Maybe some of the
fields
are
incorrect? Or are fields same for Outlook pst and WAB?

Yours appreciatively.
Angus


"Dmitry Streblechenko" <dmitry@xxxxxxxxxxx> wrote in message
news:uuCJ9YKZGHA.1352@xxxxxxxxxxxxxxxxxxxxxxx
What was the numeric error valuee returned by
pSession->OpenMsgStore()?

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

"Angus Comber" <anguscomber@xxxxxxxxxxxxxxx> wrote in message
news:OtViqzIZGHA.3328@xxxxxxxxxxxxxxxxxxxxxxx
OK ... I am learning - still waiting for my Inside MAPI CD to
arrive!!!
Hope it makes sense of MAPI for me.

Anyway, here is my code now:

if (MAPIInitialize(0) == S_OK)
printf("MAPI initialised\n");
char szError[256];
// HRESULT MAPILogonEx(ULONG ulUIParam, LPTSTR lpszProfileName,
LPTSTR
lpszPassword, FLAGS flFlags,
// LPMAPISESSION FAR * lppSession)
ULONG ulFlags = 0;
ulFlags = ulFlags | MAPI_LOGON_UI | MAPI_NO_MAIL | MAPI_EXTENDED;
LPMAPISESSION pSession = NULL;
// HRESULT hr = MAPILogonEx(0, 0, 0, MAPI_USE_DEFAULT |
MAPI_EXPLICIT_PROFILE, &pSession);
HRESULT hr = MAPILogonEx(0, 0, 0, ulFlags, &pSession);
SCODE sc = S_OK;
LPMAPITABLE pMAPITable = NULL;
hr = pSession->GetMsgStoresTable(0, &pMAPITable); // only flag
seems
to
be
MAPI_UNICODE
// Columns in contents table.
//Used to filter the columns for enumerating emails using MAPI
SizedSPropTagArray ( 2, rgPropTag ) =
{
2,
{
PR_ENTRYID, // its unique across directory
PR_DISPLAY_NAME
}
};
// Set columns we want
hr = pMAPITable->SetColumns((LPSPropTagArray)&rgPropTag, 0 );
SRowSet* pSRowSet = NULL;
hr = pMAPITable->QueryRows(1, 0, &pSRowSet);

IMsgStore* pStore = NULL;
hr = pSession->OpenMsgStore(0,
pSRowSet->aRow[0].lpProps[0].Value.bin.cb,
(ENTRYID *)pSRowSet->aRow[0].lpProps[0].Value.bin.lpb,
NULL,
0,
&pStore);

// can use HR_FAILED to check hr value
MAPIERROR* pMapiError = NULL;
pSession->GetLastError(hr, 0, &pMapiError);

But I get this error description now:
An unexpected error has occurred. MAPI was unable to load the
information
service mspst.dll. Be sure the service is correctly installed and
configured.

Any ideas what's wrong now?

Error on OpenMsgStore function. Is this correct function? My
development
machine has a few contacts in the Contacts folder in Outlook.
Not
using
Exchange Server. Outlook opens up fine.

Angus





"Dmitry Streblechenko" <dmitry@xxxxxxxxxxx> wrote in message
news:uoEVD9mYGHA.1764@xxxxxxxxxxxxxxxxxxxxxxx
0x8004010F is MAPI_E_NOT_FOUND. Did you call
IMAPITable::SetColumns()
specifying the PR_ENTRYID property before you call QueryRows()?

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

"Angus Comber" <anguscomber@xxxxxxxxxxxxxxx> wrote in message
news:Ozp1x2mYGHA.2136@xxxxxxxxxxxxxxxxxxxxxxx
The error is:

An unexpected error has occurred. MAPI was unable to load the
information
service PSTPRX.DLL. Be sure the service is correctly
installed
and
configured.

Now I have setup Outlook without email - ie there is no email
account -
only
using Contacts. Is this the problem? Surely I should still
be
able
to
get
the Contacts? Or are these functions only getting the email
messagestore?

Angus


"Angus Comber" <anguscomber@xxxxxxxxxxxxxxx> wrote in message
news:O2x73xmYGHA.460@xxxxxxxxxxxxxxxxxxxxxxx
I am now trying this:
LPMAPITABLE pMAPITable = NULL;

hr = pSession->GetMsgStoresTable(0, &pMAPITable); // only
flag
seems
to
be
MAPI_UNICODE

SRowSet* pSRowSet = NULL;

hr = pMAPITable->QueryRows(1, 0, &pSRowSet);

IMsgStore* pStore = NULL;

hr = pSession->OpenMsgStore(0,

pSRowSet->aRow[0].lpProps[0].Value.bin.cb,

(ENTRYID *)pSRowSet->aRow[0].lpProps[0].Value.bin.lpb,

NULL,

0,

&pStore);

OpenMsgStore returns 0x8004010F

Angus





"Angus Comber" <anguscomber@xxxxxxxxxxxxxxx> wrote in message
news:OOFUlkmYGHA.1196@xxxxxxxxxxxxxxxxxxxxxxx
OK I tried this:

LPMAPITABLE pMAPITable = NULL;

hr = pSession->GetMsgStoresTable(0, &pMAPITable); // only
flag
seems
to
be
MAPI_UNICODE

LPMDB pMDB = NULL;

ULONG nEntryID = 0;

LPENTRYID pEntryID = NULL;

hr = pSession->OpenMsgStore(0, nEntryID, pEntryID, 0,
MAPI_BEST_ACCESS
|
MDB_NO_MAIL, &pMDB);

But OpenMsgStore returns 0x80040107 and of course I get a
null
LPMDB
pointer. What am I doing wrong?

Angus








"Dmitry Streblechenko" <dmitry@xxxxxxxxxxx> wrote in
message

news:OWSXDwlYGHA.4060@xxxxxxxxxxxxxxxxxxxxxxx
If you need to read the IPM.Contact messages, start with
the
IMAPISession::GetMsgStoresTable,
IMAPISession::OpenMsgStore,
then
read
the
IPM.Contact messages from IMAPIFolder objects that you
open
either
by
reading PR_IPM_CONTACT_ENTRYID from the Inbox (if you
only
need
the
default
Contacts folder) or by recursively traversing the folders
starting
with
the
IPM root folder.
In case of the regular address book entries, you already
call
OpenAddressBook(). You then need to call
IAddrBook::OpenEntry(0,
NULL,
...)
to open the root container (IABContainer); then read the
containers
recursively. OAB address book provider just happens to
base
its
storage
on
the IPM.Contact messages. Other AB providers (Exchange,
LDAP,
etc)
do
not
use messages at all.
Play with the various MAPI objects with MFCMAPI or
OutlookSpy
(url
below)
to
better understand how the pieces fit together.

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

"Angus Comber" <anguscomber@xxxxxxxxxxxxxxx> wrote in
message
news:ulARodkYGHA.4760@xxxxxxxxxxxxxxxxxxxxxxx
Good question. But I am primarily thinking about the
items
in
the
Contacts
folder - yes accessible via the folder tree. And
subfolders.
I
understand
that sometimes the email address book can be
different -
is
that
then
the
Windows Address Book? WAB file? If not WAB would be
interested
to
know

how
you get access to that also.

Angus


"Dmitry Streblechenko" <dmitry@xxxxxxxxxxx> wrote in
message
news:uFrBAFaYGHA.3604@xxxxxxxxxxxxxxxxxxxxxxx
Do you mean contact entries as in what you see when
you
open
the
address
book (Tools | Address Book) or as in IPM.Contact
messages
in
one
of
the
contact folders accessible through the folder tre view
in
Outlook?

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

"Angus Comber" <anguscomber@xxxxxxxxxxxxxxx> wrote in
message
news:%23ijMoq7XGHA.752@xxxxxxxxxxxxxxxxxxxxxxx
Hello

Code below is what I have achieved so far. Problem
is
I
am
a
bit
stuck
as
to how to get any further. I want to extract all
the
contact
entries.
I
could start by first just getting Display Name.
Anything
really.
What
do
I
do next?

This is a console app and I have include mapix.h and
linked
mapi32.lib

if (MAPIInitialize(0) == S_OK)
printf("MAPI initialised\n");

ULONG ulFlags = 0;
ulFlags = ulFlags | MAPI_LOGON_UI | MAPI_NO_MAIL |
MAPI_EXTENDED;
LPMAPISESSION pSession;
HRESULT hr = MAPILogonEx(0, 0, 0, MAPI_USE_DEFAULT |
MAPI_EXPLICIT_PROFILE,
&pSession);

LPADRBOOK pAB;
hr=pSession->OpenAddressBook(0, 0, AB_NO_DIALOG,
&pAB);

But not sure now how to iterate through contact
items
getting
contents.
Any
help would be much appreciated.

Angus

































.



Relevant Pages

  • Re: What is next step to extracting PST contact items
    ... Yep, OOM still works, even most Extended MAPI pieces are fine as long as ... OutlookSpy - Outlook, CDO ... and MAPI Developer Tool ... An unexpected error has occurred. ...
    (microsoft.public.win32.programmer.messaging)
  • Re: What is next step to extracting PST contact items
    ... An unexpected error has occurred. ... Outlook as default email in IE Tools... ... and MAPI Developer Tool ... Error on OpenMsgStore function. ...
    (microsoft.public.win32.programmer.messaging)
  • Re: How to replace an attachment from a file.wav to a winmail.dat
    ... And it will not have Outlook installed on. ... when the code tries to convert back from MAPI to MIME using the ... we created one stream object with the contents of the file using the ... and we created the new tnef stream using the OpenTnefStreamEx ...
    (microsoft.public.win32.programmer.messaging)
  • Re: What is next step to extracting PST contact items
    ... An unexpected error has occurred. ... Play with the various MAPI objects with MFCMAPI or OutlookSpy (url ... OutlookSpy - Outlook, CDO ... folder - yes accessible via the folder tree. ...
    (microsoft.public.win32.programmer.messaging)
  • Re: Programming a syncrhonisation with Outlook
    ... I tried MAPI before but to my opinion you only can use MAPI for sending and ... That limits you to using the Outlook Object Model. ... and MAPI Developer Tool ... I'd like to develop a synchronisation with Outlook. ...
    (microsoft.public.outlook.program_vba)