Solved

Help : Reading Outlook Address book with Mapi

Posted on 1998-09-14
21
559 Views
Last Modified: 2010-04-06
hi there,
I need a help on How to Read/import Mapi Address book and/or Mapi messages in delphi3.
to say how to get Outlook address book in my delphi program  notice that i need to use extended mapi.
any component,suggestion,comment are welcomed.

if u need more information either put a comment or contact me by email: niceguy25@geocities.com
0
Comment
Question by:dyancer
  • 11
  • 7
  • 3
21 Comments
 
LVL 7

Expert Comment

by:BlackMan
ID: 1339641
Are you completly bound to using EMAPI? It would be much easier using Outlook objects...
Do you have MAPI up and running allready? You need to look at the AddressBook method of the MAPI session.
0
 
LVL 1

Author Comment

by:dyancer
ID: 1339642
thanx BlackMan for your comment,
I'm not bound to any MAPI implementation, i can use any MAPI implementation that take me to the target "geting the outlook AddressBook",
either it was an EMAPI or Outlook Object "Active Mapi Messaging".
the Only limitation for not using Outlook Object is that i don't have the Header files translated to Delphi.
 
Dyancer.
0
 
LVL 7

Expert Comment

by:BlackMan
ID: 1339643
How about OLE, is that an option?
0
 
LVL 1

Author Comment

by:dyancer
ID: 1339644
Nope,
The Whole idea is to read all the Address book seamlessly... to say, without annoying the user with alot of dialogs, just One dialog that i build to hold the information,
and this can't be done "i think"  using OLE.

0
 
LVL 7

Expert Comment

by:BlackMan
ID: 1339645
You can indeed talk OLE to Outlook without the user knowing anything about.. Like this

myOLEApp := CreateOLEObject('Outlook.Application');
myNameSpace := myOLEApp.GetNameSpace('MAPI');
myPublicFolder := myNameSpace.Folders['Public Folders'].Folders;
myAllPublicFolder := myPublicFolder.Item['All PublicFolders'].Folders;
myToDoFolder := myAllPublicFolder.Item['Max Development'];
myTaskFolder := mytoDoFolder.Folders['To Do'];
0
 
LVL 1

Author Comment

by:dyancer
ID: 1339646
it seems like it worh a try ...
so, i need more information about this techneque.
do u have any sample code in delphi .. or any other documentation,
(* what type those varialbes in the prev example was *)


thanx.
0
 
LVL 7

Expert Comment

by:BlackMan
ID: 1339647
The variables is of type Variant
As fas as I remember, I have a code example at home, I'll look it up tonight..
0
 
LVL 1

Author Comment

by:dyancer
ID: 1339648
please send me any code or explanation.
0
 
LVL 7

Expert Comment

by:BlackMan
ID: 1339649
Sorry for the delay, I've been quite busy..
I've fiddled around with some of my old code to try to read Contacts, but haven't quite succeded yet. As I'm out of town for the next week, I'll post the code here, it might give you a clue... (the problem is the properties on the Contact element)
A good source to find more information about it, is www.microsoft.com/outlookdev. There are some VB examples as far as I remember..

---------------------------------
unit OLu;

interface

uses
 StdCtrls, Classes, Controls, Forms, Dialogs;

type
  TForm1 = class(TForm)
    Button1: TButton;
    lb: TListBox;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

Const
// OlDefaultFolders
  olFolderDeletedItems = 3;
  olFolderOutbox = 4;
  olFolderSentMail = 5;
  olFolderInbox = 6;
  olFolderCalendar = 9;
  olFolderContacts = 10;
  olFolderJournal = 11;
  olFolderNotes = 12;
  olFolderTasks = 13;

var
  Form1: TForm1;

implementation

Uses
  ComObj;

{$R *.DFM}

procedure TForm1.Button1Click(Sender: TObject);
Var
  MyFolder,
  MyFolders,
  MyFolderItems,
  MyContact,
  myApp,
  myMapi,
  myContacts      : Variant;
  f,a,
  I      : Integer;
begin
  myApp := CreateOleObject('Outlook.Application');
  myMAPI := myApp.GetNameSpace('MAPI');

    MyFolders := MyMAPI.Folders(1);
    MyFolders := MyFolders.Folders;
    For i := 1 to MyFolders.Count do
    begin
       MyFolder := Mymapi.Folders(i);
       lb.items.Add('Folder ' + MyFolder.Name);
    end;


  MyFolder := myMAPI.GetDefaultFolder(olFolderContacts);
  MyFolderItems := MyFolder.Items;
   a := MyFolderItems.Count;
    For i := 1 to a do
    begin
       MyContact := MyFolder.Items(i);
       lb.items.add(mycontact.EMailAddress);  // <-- Here is the problem
    End;

end;

end.

0
 
LVL 7

Expert Comment

by:BlackMan
ID: 1339650
Hi Dyancer, have you played with the code?
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 1

Author Comment

by:dyancer
ID: 1339651
Hello BlackMan,
I Got your Code, in the meanwhile time i wrote a program to Read AddressBook using VB5 and i wondered to see that this code is a translation from the VB.
so, i got the code and correct it to work properly.

procedure something;
var   myMapiSession: Variant;
begin
  myMapiSession:= CreateOleObject('MAPI.Session');
  myMapiSession.Logon;
  ShowMessage(MyMapiSession.Application+' === ' + MyMapiSession.Version);  { this should display 'Ole Messagin 1.0' or 1.1 }
{
 for now you have a seesion and u can further work with this session to
 get address book or any thing else like this
.
MyRecipient:=MyMapiSession.AddressBook; {MyRecipient was declared as a Variant }
.
}
 MyMapiSession.LogOut; { close seesion }
end;

thanx a lot for ur code...

dyancer {hassan}

0
 
LVL 7

Expert Comment

by:BlackMan
ID: 1339652
Do you want me to submit the code as an answer or did you solve the problem without my code?
0
 
LVL 1

Author Comment

by:dyancer
ID: 1339653
hi BlackMan,
your code was a good HINT for solving the problem using Delphi.
please Submit your comment as an answer and get the WHOLE points.

thanx
Dyancer {hassan}

0
 
LVL 7

Accepted Solution

by:
BlackMan earned 250 total points
ID: 1339654
Thanks...

--------------- snip ---------------------
unit OLu;

interface

uses
 StdCtrls, Classes, Controls, Forms, Dialogs;

type
  TForm1 = class(TForm)
    Button1: TButton;
    lb: TListBox;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

Const
// OlDefaultFolders
  olFolderDeletedItems = 3;
  olFolderOutbox = 4;
  olFolderSentMail = 5;
  olFolderInbox = 6;
  olFolderCalendar = 9;
  olFolderContacts = 10;
  olFolderJournal = 11;
  olFolderNotes = 12;
  olFolderTasks = 13;

var
  Form1: TForm1;

implementation

Uses
  ComObj;

{$R *.DFM}

procedure TForm1.Button1Click(Sender: TObject);
Var
  MyFolder,
  MyFolders,
  MyFolderItems,
  MyContact,
  myApp,
  myMapi,
  myContacts : Variant;
  f,a,
  I : Integer;
begin
  myApp := CreateOleObject('Outlook.Application');
  myMAPI := myApp.GetNameSpace('MAPI');

    MyFolders := MyMAPI.Folders(1);
    MyFolders := MyFolders.Folders;
    For i := 1 to MyFolders.Count do
    begin
MyFolder := Mymapi.Folders(i);
lb.items.Add('Folder ' + MyFolder.Name);
    end;


  MyFolder := myMAPI.GetDefaultFolder(olFolderContacts);
  MyFolderItems := MyFolder.Items;
   a := MyFolderItems.Count;
    For i := 1 to a do
    begin
MyContact := MyFolder.Items(i);
lb.items.add(mycontact.EMailAddress);  // <-- Here is the problem
    End;

end;

end.
0
 
LVL 6

Expert Comment

by:Stuart_Johnson
ID: 1339655
Blackman:  Is there a way this can work with OutLook Express at all??  Im quite happy to open a new q. for it, but just thought I'ld ask first before hand.

Stu
0
 
LVL 7

Expert Comment

by:BlackMan
ID: 1339656
I guess you could use it OE too, but I've never tried. It ought to work with the exact same code..
0
 
LVL 6

Expert Comment

by:Stuart_Johnson
ID: 1339657
No it didnt.  I was expecting it would too.  Maybe Express has a different interface then Outlook??  How would I find out what to call.  There is no TLB that I can find for OE :(

Cheers,

Stu.
0
 
LVL 7

Expert Comment

by:BlackMan
ID: 1339658
Seems like there is no interface for OE?!
I'm sorry, I can't help you.. :-(
0
 
LVL 6

Expert Comment

by:Stuart_Johnson
ID: 1339659
Typical of good old MS :)

Thats fine.  Just thought I'd ask while the question was still fresh :)

What part of the world are you from?  That was a very quick response.  Im in Australia, Sydney almost.  11:15pm on 19/2.  Is it just moring for you or something?

Anyway, thanks for getting back to me on this.  Much appreciated!

Stu.
0
 
LVL 7

Expert Comment

by:BlackMan
ID: 1339660
I'm in Aalborg, Denmark and it's 1:15 PM here now... So goodnight to you :-)
0
 
LVL 1

Author Comment

by:dyancer
ID: 1339661
Hello there...
if any of you got the answer on how to get the Outlook Express
Address book then please post it here or notify me by email so i
can post a new question so u can get some points...

tell now, i found that Outlook Express does not support "Active messaging".
I tried to use Extended Mapi and for no avail...

thanx in advance.
Dyancer
niceguy25@geocities.com

0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
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: …

708 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