Autor Beitrag
UGrohne
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Veteran
Beiträge: 5502
Erhaltene Danke: 220

Windows 8 , Server 2012
D7 Pro, VS.NET 2012 (C#)
BeitragVerfasst: Di 24.12.02 14:06 
Hallo Leute,
wie kann ich Adressen aus Outlook auslesen, auflisten und bei gewählten die einzelnen Daten auslesen. Irgendwie hab ich mit der Suche nix gscheites gefunden (oder bin zu blöd) und selbst hinbekommen hab ichs bisher au net. Ne kleine Info über die nötigen Funktionen und Kompos würde mir reichen.

Danke
Popov
Gast
Erhaltene Danke: 1



BeitragVerfasst: Di 24.12.02 14:15 
Ist leider ein wenig mehr als das man es in einigen Worten erklären könnte. Außerden ist heute Weihnachten. Du hast dir also keine perfekte Zeit für deine Frage rausgesucht.

Das Stichwort ist aber: "OLE-Automation"
DaFox
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 189



BeitragVerfasst: Di 24.12.02 14:30 
Hi.

ausblenden volle Höhe Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
procedure TForm1.Button1Click(Sender: TObject);
const
  olContactItem = 2;

var
  I: integer;
  MyFolder: variant;
  OleApp: variant;
  NameSpace: variant;

begin
  { Create the Ole object.}
  OleApp:= CreateOleObject('Outlook.Application');

  { Get the MAPI interface.}
  NameSpace:= OleApp.GetNameSpace('MAPI');

  { Get all folders.}
  MyFolder:= NameSpace.Folders('Personal Folders');

  { Empty the folders combobox.}
  cbFolders.Clear;

  { Loop over all folders...}
  for I:= 1 to MyFolder.Folders.Count do
    begin
      { If the folder contains contacts then add it to the combobox.}
      if (MyFolder.Folders.Item[I].DefaultItemType = olContactItem) then
cbFolders.Items.Add(MyFolder.Folders.Item[I].Name);
    end;
end;

procedure TForm1.cbFoldersChange(Sender: TObject);
var
  I: integer;
  MyFolder: variant;
  CurFolder: variant;
  OleApp: variant;
  NameSpace: variant;

begin
  { Create the Ole object.}
  OleApp:= CreateOleObject('Outlook.Application');

  { Get the MAPI interface.}
  NameSpace:= OleApp.GetNameSpace('MAPI');

  { Get all folders.}
  MyFolder:= NameSpace.Folders('Personal Folders');

  { Get all folders.}
  CurFolder:= MyFolder.Folders.Item(cbFolders.Items[cbFolders.ItemIndex]);

  { Empty the contacts listbox.}
  lbContacts.Clear;

  { Loop over all folders...}
  for I:= 1 to CurFolder.Items.Count do
    begin
      { If the folder contains contacts then add it to the combobox.}
      lbContacts.Items.Add(CurFolder.Items[I].FullName);
    end;
end;


Gruß,
Markus
Popov
Gast
Erhaltene Danke: 1



BeitragVerfasst: Di 24.12.02 14:53 
Das funktioniert aber nur für das lokale Postfach. Wenn du im Netzwerk arbeitest, dann kommst du mit dem Code nicht weiter.

Außerdem mußt du für das Beispiel die Unit "ComObj" einbinden.
DaFox
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 189



BeitragVerfasst: Di 24.12.02 15:18 
Klar, hab' nichts anderes behauptet.

Gruß,
Markus
UGrohne Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Veteran
Beiträge: 5502
Erhaltene Danke: 220

Windows 8 , Server 2012
D7 Pro, VS.NET 2012 (C#)
BeitragVerfasst: Di 24.12.02 15:46 
Thx, ich probier das gleich mal aus.

Jo, dass Weihnachten ist hab ich am Rande auch so mitgekriegt *g*, aber das hindert mich nicht daran zu Arbeiten, selbst meine Chefin hat mich heute zum Arbeiten verdonnert, dann kann ich danach auch gleich weitermachen *g*.

Bin mal kurz testen, meld mich dann vll heut nochmal mit Problemen *g*
UGrohne Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Veteran
Beiträge: 5502
Erhaltene Danke: 220

Windows 8 , Server 2012
D7 Pro, VS.NET 2012 (C#)
BeitragVerfasst: Di 24.12.02 16:10 
Ok, das funktioniert ganz gut, muss halt nochn bissi rumprobieren.

Musste aber den String bei MyFolder (Personal Folder) ändern. Da gibts doch den Dialog, wo man das auswählen kann, weil der muss ja stimmen. Kann man den irgendwie aufrufen?

Achja, und gibts irgendwo eine Doku, wo man die ganzen unterstützten Objekte, wie Name, Vorname usw. kriegen kann, weil Delphi hilft einem in der Hinsicht ja gar net weiter.

So, jetzt nochn schönen Heilig Abend und vielen Dank für die Mühe