[Webinar] Learn how to a build a cloud-first strategyRegister Now

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

Help : Reading Outlook Address book with Mapi

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
dyancer
Asked:
dyancer
  • 11
  • 7
  • 3
1 Solution
 
BlackManCommented:
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
 
dyancerAuthor Commented:
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
 
BlackManCommented:
How about OLE, is that an option?
0
Independent Software Vendors: 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!

 
dyancerAuthor Commented:
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
 
BlackManCommented:
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
 
dyancerAuthor Commented:
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
 
BlackManCommented:
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
 
dyancerAuthor Commented:
please send me any code or explanation.
0
 
BlackManCommented:
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
 
BlackManCommented:
Hi Dyancer, have you played with the code?
0
 
dyancerAuthor Commented:
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
 
BlackManCommented:
Do you want me to submit the code as an answer or did you solve the problem without my code?
0
 
dyancerAuthor Commented:
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
 
BlackManCommented:
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
 
Stuart_JohnsonCommented:
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
 
BlackManCommented:
I guess you could use it OE too, but I've never tried. It ought to work with the exact same code..
0
 
Stuart_JohnsonCommented:
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
 
BlackManCommented:
Seems like there is no interface for OE?!
I'm sorry, I can't help you.. :-(
0
 
Stuart_JohnsonCommented:
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
 
BlackManCommented:
I'm in Aalborg, Denmark and it's 1:15 PM here now... So goodnight to you :-)
0
 
dyancerAuthor Commented:
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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 11
  • 7
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now