Solved

Outlook Email Addressbook

Posted on 2004-04-01
5
209 Views
Last Modified: 2010-04-05
Hello !
  I've created a little application which get's a list of email addresses from the outlook addressbook (on an exchange server) along with their login name.  

Does anyone know if its possible to just return names (rather than groups) from the email address list ?

Also does anyone know if its possible to return their alias ?  (When you right click a name, chose properties it displays it there).

This is the addressbook NOT the contact list.

Many thanks in advance.
0
Comment
Question by:Togs
5 Comments
 
LVL 22

Expert Comment

by:Ferruccio Accalai
Comment Utility
maybe this can help?

uses Mapi

procedure TForm1.Button1Click(Sender: TObject);
Function GetAddressBookNames(const ToList,CCList,BCCList: TStrings; DialogCaption: String): Boolean;
  type
  AFUlong = Cardinal; //Windows.ULONG Type compatibility for D3
var
  lpRecip: TMapiRecipDesc;
  intRecips: AFULONG;
  lpRecips: PMapiRecipDesc;
  i: Integer;
  NumberOfEditFields: Cardinal ;
begin
  NumberOfEditFields := 0;
  If (ToList <> Nil) or  (CCList <> Nil) or (BCCList <> Nil) then
    Inc(NumberOfEditFields);
  result := False;
  if (MAPIAddress(0, Application.Handle, PChar(DialogCaption),
    NumberOfEditFields, '', 0, lpRecip, 0, 0, @intRecips, lpRecips) =
    SUCCESS_SUCCESS) then
  begin
    If NumberOfEditFields > 0 then
    begin
      for i := 0 to intRecips-1 do
        case PMapiRecipDesc(PChar(lpRecips) + i*SizeOf(TMapiRecipDesc))^.
          ulRecipClass of
          MAPI_TO:
            If ToList <> nil then ToList.Add(PMapiRecipDesc(PChar(lpRecips) +
              i*SizeOf(TMapiRecipDesc))^.lpszName);
          MAPI_CC:
            If CCList <> nil then CCList.Add(PMapiRecipDesc(PChar(lpRecips) +
              i*SizeOf(TMapiRecipDesc))^.lpszName);
          MAPI_BCC:
            If BCCList <> nil then BCCList.Add(PMapiRecipDesc(PChar(lpRecips)
              + i*SizeOf(TMapiRecipDesc))^.lpszName); //.lpszAddress for Address....
        end;
      result := True;
    end;
  end;
  MAPIFreeBuffer(lpRecips);
end;
begin
getaddressbooknames(listbox1.Items,nil,nil,'');
end;
0
 

Author Comment

by:Togs
Comment Utility
Thanks for that although it doesn't quite help my problem.  

I need to check a login (for example one you log into the network with 'test07' which then has an email account based on this login 'test07').

I have statics in my application which upon certain events automatically email specific logins (for example 'test07').  However when these are removed from the exchange server and not the application it produces problems with my application (allows the users to type their own email addresses in and due to the poor handling of windows in XP also sometimes get stuck behind other windows).
0
 

Accepted Solution

by:
modulo earned 0 total points
Comment Utility
PAQed with points refunded (60)

modulo
Community Support Moderator
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
This video discusses moving either the default database or any database to a new volume.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

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

13 Experts available now in Live!

Get 1:1 Help Now