?
Solved

Help : Reading Outlook Address book with Mapi

Posted on 1998-09-14
21
Medium Priority
?
567 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
[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
  • 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
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 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
 
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 500 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

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…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Suggested Courses

770 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