Solved

Address Book Programming

Posted on 2002-06-19
12
271 Views
Last Modified: 2013-11-20
Hi All,

How can i write a application to access the address book of my MS Outlook (preferably in VC++).
I don't know any MAPI, so would appericaiate if you could give me the code right from scratch.

Thanx in Advance,
Neel
0
Comment
Question by:neelmanasi
  • 6
  • 5
12 Comments
 
LVL 12

Expert Comment

by:migel
ID: 7092594
Hi
There is book
"Inside MAPI" by Irving De la Cruz and Les Thaler
also there are several example in the MSDN about using MAPI
you need search it for ABVIEW.CLI
if you not found it let me know your Email I`ll send it to you.
good luck!
0
 
LVL 86

Expert Comment

by:jkr
ID: 7092988
0
 

Author Comment

by:neelmanasi
ID: 7093750
Thanx Migel

I got the samples,
But is there a simple implementation ???
so that i can include it in any MFC project & use it.

Thanx
Neel
neelkeer@optonline.net
0
 
LVL 12

Expert Comment

by:migel
ID: 7095461
Hi!
MFC examples sended hope MFC classes can be easely incorporated into the your program.
0
 

Author Comment

by:neelmanasi
ID: 7096882
Hi Migel,

Thanx for the email.

But those examples are too complicated & cannot be incorporated into a new MFC application.

NEEL
0
 
LVL 12

Expert Comment

by:migel
ID: 7097952
hm
MAPI is too big for simple tasks
so What to do you want with Address Books?
May be Simple MAPI or CDO object will be preffered?
0
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 
LVL 12

Expert Comment

by:migel
ID: 7098002
hm
MAPI is too big for simple tasks
so What to do you want with Address Books?
May be Simple MAPI or CDO object will be preffered?
0
 

Author Comment

by:neelmanasi
ID: 7098382
I want to just write a app which can read my MS outlook Address Book & extract some selected fields of the contacts to a flat file. I know this can be done from outlook but i want to write a app so that i can run this app anytime without the manual export from outlook.
Neel
0
 
LVL 12

Expert Comment

by:migel
ID: 7098396
Ok
Is your program will work with Outlook ONLY? or any other MAPI compliant MailClients required?
Working with WAB (as JKR pointed to) is preffered in 1 case.
0
 

Author Comment

by:neelmanasi
ID: 7098433
Yes, Only with MS Outlook (not Outllok Express) Address Book. I don't need any other mail related APIs
Neel
0
 

Author Comment

by:neelmanasi
ID: 7102189
Hey Migel,

I tried does examples, they are great.
But i found out that one can only resolve a name from an email address or get a email address from a name.

Is there any API which can give any details i want from a contact, e.g. home phone, off. ph., etc.

Thanx
Neel
0
 
LVL 12

Accepted Solution

by:
migel earned 200 total points
ID: 7102859
Hi! this AB entries can be readed  through properties MAPI mechanism.
for example:

{
//display the Address Dialog
       LPSTR    rglpszDestTitles[1];
       ULONG    rgulDestComps[1];
       ULONG    ulFlags           = 0;
       ULONG    ulUIParam         = 0;

       ulFlags = ulFlags | DIALOG_MODAL;

       rglpszDestTitles[0]        = "To";
       rgulDestComps[0]           = MAPI_TO;

       ADRPARM  adrparm;
       adrparm.cbABContEntryID    = 0;
       adrparm.lpABContEntryID    = NULL;
       adrparm.ulFlags            = ulFlags;
       adrparm.lpReserved         = NULL;
       adrparm.ulHelpContext      = 0;
       adrparm.lpszHelpFileName   = NULL;
       adrparm.lpfnABSDI          = NULL;
       adrparm.lpfnDismiss        = NULL;
       adrparm.lpvDismissContext  = NULL;
       adrparm.lpszCaption        = "MAPI ITP tests Address 1";
       adrparm.lpszNewEntryTitle  = "For this test dialog";
       adrparm.lpszDestWellsTitle = "Selected Recipients:";
       adrparm.cDestFields        = 1;
       adrparm.nDestFieldFocus    = 0;
       adrparm.lppszDestTitles    = rglpszDestTitles;
       adrparm.lpulDestComps      = rgulDestComps;
       adrparm.lpContRestriction  = NULL;
       adrparm.lpHierRestriction  = NULL;

       if( FAILED(hResult = lpAdrBook->Address( &ulUIParam,
                                       &adrparm, &lpadrlist )))
       {
         //printf ( " FAILED with error: %X\r\n", hResult );
         goto error;
       }
       else
         //printf ( " OK\r\n" );
     }

     if (!lpadrlist)
       goto error;

     {
       ULONG   cEntry   = 0;
       ULONG   cProp   = 0;

       for(cEntry=0; cEntry<lpadrlist->cEntries; cEntry++)
       {
         for(cProp=0;
             cProp < lpadrlist->aEntries[cEntry].cValues;
             cProp++)
         {
           //printf ( "   >Name: " );
//here we check only for display name property
// but You can check for any desired property
           if( lpadrlist->aEntries[cEntry].rgPropVals[cProp].ulPropTag
               == PR_DISPLAY_NAME )
           {
             //printf (lpadrlist->aEntries[cEntry].rgPropVals[cProp].Value.LPSZ);
             //printf ( " ...\r\n" );
             break;
           }
         }
// here we try find EntryID in the props list
// you also can try for something else :-)
         //printf ( "    -->Find EntryID " );

         LPSPropValue lpsPropVal = NULL;
         lpsPropVal = PpropFindProp (
                          lpadrlist->aEntries[cEntry].rgPropVals,
                          lpadrlist->aEntries[cEntry].cValues,
                          PR_ENTRYID );
          if (lpsPropVal)
           MAPIFreeBuffer(lpsPropVal);


        if (lpadrlist)
          _FreeRowSet((LPSRowSet) lpadrlist);
}

void _FreeRowSet( LPSRowSet lpRows )
    {
      ULONG cRows;

      if ( !lpRows )
        return;

      for( cRows = 0; cRows < lpRows->cRows; ++cRows )
      {
        MAPIFreeBuffer( lpRows->aRow[cRows].lpProps );
      }

      MAPIFreeBuffer( lpRows );
    }
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now