Solved

Address Book Programming

Posted on 2002-06-19
12
276 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
Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

 
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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Strange date stored 22 122
set up trigger (or something) to rename files (starting with ATL) in a linux directory 6 53
sum28 challenge 31 112
Way to decrease size of apk file 9 67
In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

773 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