Solved

Address Book Programming

Posted on 2002-06-19
12
279 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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
 
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Creating Labels and Frequency list style reports in SAS code 9 113
Whole sheet autoscrub still needed 19 53
Define unique primary key 9 95
modThree challenge 4 105
This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
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.

749 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