address book access of MS Outlook

R

Rohan lotlikat

Hi

Following code has a problem :
m_lpAdrBook->GetPAB(&ulEntryID,&lpEntryID);

LPCIID lpInterface = NULL;
ULONG ulFlags = 0;//MAPI_BEST_ACCESS;
ULONG ulObjType;
if(ulEntryID && lpEntryID)
LPABCONT m_pIABCon;
m_lpAdrBook->OpenEntry(ulEntryID,lpEntryID,NULL,ulFlags,
&ulObjType,(LPUNKNOWN*)&m_pIABCon);

LPMAPITABLE pIMPTable;

if(m_pIABCon)
m_pIABCon->GetContentsTable(0,&pIMPTable);
SizedSPropTagArray ( 3, sptCols ) = { 3,
PR_ENTRYID,
PR_DISPLAY_NAME,PR_EMAIL_ADDRESS };
LPSRowSet pABCRows = NULL;
HrQueryAllRows
(pIMPTable,(SPropTagArray*)&sptCols, NULL, NULL, 0,&pABCRows);

pABCRows->cRows is 0

Can you help her please .. i cant figure out whats going wrong.

Regards
Rohan
 
D

Dmitry Streblechenko

Which address container is configured as a PAB? What do you see in
OutlookSpy (click IAddrBook, GetPAB)?

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

Rohan lotlikat

Hi Dmitry

Unfortunately my Outlook Spy has expired. I cant use it any more.

Do i need to setPAB explicity ? Can u help me withsample code of grabbing
addresses from MS Outlook using pure MAPI?

HrFindExchangeGlobalAddressList needs edk.h thats creates linking problems.

I also tried the other way:
I used MSOUT.OLB
--got MAPI namespace
--got olFolderContacts folders
--got items from folders
--looped thru the items and got contactItem Ptr for each.
--then pContact->get_MAPIOBJECT(&pUnk); for each contact..
--then used HrGetOneProp((IMAPIProp*)pUnk,flags,(LPSPropValue FAR *)&lpsProp)
;

BUT it does not work ..i set flag to PR_EMAIL_ADDRESS

dmitry can u help me out please ..

regards
Rohan
 
D

Dmitry Streblechenko

HrFindExchangeGlobalAddressList returns GAL, it has nothing to do with PAB.
The PAB can be set in the Outlook UI: open the address book window
(Ctrl+Shift+B) and select Tools|Options. What does "Keep personal addresses
in" show?

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

Rohan lotlikat

Hey Dmitry
"Keep personla addresses " shows contacts

But i got it working .. i used
m_lpAddrBook->GetDefaultDir(&ulEntry,&lpEntryId);
this waorks fine .. i hope its the right way.

Thanx a lots dmitry
I need little more help on thread ...
i uses
_beginthreadex(NULL,5000000,Find,(void*)Obj,0,&notUsed);
and in Find() i run through all the messages in all the folders..(each and
every ) ..
I get stack overflow and sometimes no memory error... why is that? do i need
to increase stack size?

I use CComPtrs in the Find() ..so i guess there should not be mem leak..Can
you please me here?

regards
Rohan
 
D

Dmitry Streblechenko

Do not perform search by reading each and every message. Use either
MAPIFolder.Items.Find/FindNext or Restrict in Outlook Object Model or
IMAPITable::FindRow/Restrict in Extended MAPI.
I have no idea about the stack overflow - impossible to tell without seeing
(and running) the code.

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

Rohan lotlikat

Hi Dmitry

Actually i need to search each message as i am not search for any particular
item ..i need search each message and show what i find.

also i cam across a new problem.
mFolder->get_items(pContacts);
pContacts->find("[Email1Address = (e-mail address removed)]",&pDisp);

The above code does not find the contact.But if there is no '.' in the
search string it works fine . like below

pContacts->Find("[Email1Address = (e-mail address removed)]",&pDisp);

can you help as to what is right way to use Find()

Regards
Rohan
 
D

Dmitry Streblechenko

I really don't know, I don't use OOM for searching.
Are you sure you have the syntax right? Shouldn't it be

("[Email1Address] = ""(e-mail address removed)""")

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

Rohan lotlikat

Hi Dmitry

yes the syntax is right. it works fine for others.

I tried a new approach using MAPI. following is the piece of code.
Upfortunately this also does not work :( (not at all)

lpIABCon->GetContentsTable(0,&pIMPTable);
//Do i need to setcolumns for find?
hres = pIMPTable->SetColumns((LPSPropTagArray)&abCol, 0);

hres = MAPIAllocateBuffer( sizeof(SRestriction),
reinterpret_cast<LPVOID*>(&pRes) );
if(FAILED(hres))
return;


lpSProp.Value.lpszA = "(e-mail address removed)";
lpSProp.ulPropTag = PR_EMAIL_ADDRESS;
pRes->rt = RES_PROPERTY;
pRes->res.resProperty.relop = RELOP_EQ; pRes->res.resProperty.lpProp =
&lpSProp; pRes->res.resProperty.ulPropTag = PR_EMAIL_ADDRESS;

hres = pIMPTable->SeekRow(BOOKMARK_BEGINNING, 0, NULL);

hres = pIMPTable->FindRow(pRes,BOOKMARK_BEGINNING,DIR_BACKWARD)
//tried NULL in place of DIR_BACKWARD too
hres has -21472...something ..
it does not match MAPI_E_NOT_FOUND or S_OK..

i tries resContent too .. can you help me here dmirty

how do you find a if the a emailaddress is already present in the address
book

Regards
ROhan
 
D

Dmitry Streblechenko

Where does lpIABCon come from? It is IMAPIFolder or IABContainer?
In case of IABContainer, note taht most AB providers only support PR_ANR
restrictions.

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top