Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 284
  • Last Modified:

Address Book Programming

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
neelmanasi
Asked:
neelmanasi
  • 6
  • 5
1 Solution
 
migelCommented:
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
 
neelmanasiAuthor Commented:
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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
migelCommented:
Hi!
MFC examples sended hope MFC classes can be easely incorporated into the your program.
0
 
neelmanasiAuthor Commented:
Hi Migel,

Thanx for the email.

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

NEEL
0
 
migelCommented:
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
 
migelCommented:
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
 
neelmanasiAuthor Commented:
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
 
migelCommented:
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
 
neelmanasiAuthor Commented:
Yes, Only with MS Outlook (not Outllok Express) Address Book. I don't need any other mail related APIs
Neel
0
 
neelmanasiAuthor Commented:
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
 
migelCommented:
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

Technology Partners: 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!

  • 6
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now