Announcement

Collapse
No announcement yet.

Outlook und Delphi

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Outlook und Delphi

    Hallo,
    wir habe hier Exchange mit Outlook laufen. Nun möchte ich gerne auf die Telefonnummern in Outlook zugreifen und in meiner Datenbank speichern.
    Gibt es eine möglichkeit von Delphi auf die Adressbücher unter Outlook 98 zuzugreifen und die Daten Wie name und Telefonnummer auszulesen !

  • #2
    Hallo,

    das folgende Beispiel demonstriert, wie die Namen und die eMail-Adresse ausgelesen werden. Die restlichen Informationen stehen jedoch ebenfalls als Eigenschaften des <b>ContactItem</b>-Interfaces zur Verfügung.
    <pre>

    <b>unit</b> KontakteD5Frm;

    <b>interface</b>

    <b>uses</b>
    Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
    StdCtrls, OleServer, Outlook2000;

    <b>type</b>
    TForm1 = <b>class</b>(TForm)
    OutlookApplication1: TOutlookApplication;
    Button1: TButton;
    ListBox1: TListBox;
    <b>procedure</b> Button1Click(Sender: TObject);
    <b>private</b>
    <font color="#003399"><i>{ Private-Deklarationen }</i></font>
    <b>public</b>
    <font color="#003399"><i>{ Public-Deklarationen }</i></font>
    <b>end</b>;

    <b>var</b>
    Form1: TForm1;

    <b>implementation</b>

    <font color="#003399"><i>{$R *.DFM}</i></font>

    <b>procedure</b> TForm1.Button1Click(Sender: TObject);
    <b>var</b>
    aNameSpace : NameSpace;
    aContacts : MAPIFolder;
    aContactItem : ContactItem;
    iCnt : Integer;
    <b>begin</b>
    OutlookApplication1.Connect;
    aNameSpace := OutlookApplication1.GetNamespace(<font color="#9933CC">'MAPI'</font>);
    aContacts := aNameSpace.GetDefaultFolder(olFolderContacts);
    <b>for</b> iCnt := 1 <b>to</b> aContacts.Items.Count <b>do</b>
    <b>begin</b>
    aContactItem := aContacts.Items.Item(iCnt) <b>as</b> ContactItem;
    ListBox1.Items.Add(Format(<font color="#9933CC">'%s : %s'</font>, [aContactItem.FirstName,
    aContactItem.Email1Address]));
    <b>end</b>;
    OutlookApplication1.Disconnect;
    <b>end</b>;

    <b>end</b>.

    </pre&gt

    Comment


    • #3
      Hallo Andreas,
      leider geht es nicht.
      Ich möchte auf das Globale Adressbuch zugreifen. Wo kann ich den das Adressbuch einstellen. Es gibt ja mehrere ?

      Tna

      Comment


      • #4
        <PRE>
        Hallo !

        Ich benutze D7 Enterprise und Windows XP pro SP1.
        Das hier angegebene Programmierbeispiel, funktioniert bei mir leider nicht.
        Ich habe alles so stehen, wie es hier abgebildet ist.
        Nur das ich halt OutlookXP an stelle von Outlook2000 habe.
        Ich erhalte immer die Fehlermeldung, dass die Klasse nicht registriert sei.
        Und dass, sobald ich auf OutlookXP connecten will.
        Kann es sein, das ich da was Neuinstallieren muss oder habe ich einen Fehler gemacht ?
        Bitte helft mir, es ist sehr wichtig !

        Gruß raven !

        </PRE>

        <PRE>
        unit Unit1;

        interface

        uses
        Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
        Dialogs, StdCtrls, OleServer, OutlookXP;

        type
        TForm1 = class(TForm)
        OutlookApplication1: TOutlookApplication;
        Button1: TButton;
        ListBox1: TListBox;
        procedure Button1Click(Sender: TObject);
        private
        { Private-Deklarationen }
        public
        { Public-Deklarationen }
        end;

        var
        Form1: TForm1;

        implementation

        {$R *.dfm}

        procedure TForm1.Button1Click(Sender: TObject);
        var
        aNameSpace : NameSpace;
        aContacts : MAPIFolder;
        aContactItem : ContactItem;
        iCnt : Integer;
        begin
        OutlookApplication1.Connect;
        aNameSpace := OutlookApplication1.GetNamespace('MAPI');
        aContacts := aNameSpace.GetDefaultFolder(olFolderContacts);
        for iCnt := 1 to aContacts.Items.Count do
        begin
        aContactItem := aContacts.Items.Item(iCnt) as ContactItem;
        ListBox1.Items.Add(Format('%s : %s', [aContactItem.FirstName,
        aContactItem.Email1Address]));
        end;
        OutlookApplication1.Disconnect;
        end;

        end.

        </PRE&gt

        Comment

        Working...
        X