Solved

Address Book Programming

Posted on 2002-06-19
12
274 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
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.

862 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

23 Experts available now in Live!

Get 1:1 Help Now