1 unit UMain;
2
3 interface
4 //If you are using Delphi 6 or greater replace OutLook_TLB with Outlook2000
5 uses
6 Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
7 ComObj, Outlook_TLB, StdCtrls;
8
9
10 type
11 TForm1 = class(TForm)
12 Button1: TButton;
13 ListBox3: TListBox;
14 Label1: TLabel;
15 procedure Button1Click(Sender: TObject);
16 private
17 { Private declarations }
18 public
19 { Public declarations }
20
21 end;
22
23 var
24 Form1: TForm1;
25
26 implementation
27
28 {$R *.DFM}
29
30 procedure TForm1.Button1Click(Sender: TObject);
31 var
32 MyOutlook : _Application;
33 MyNameSpace : _NameSpace;
34 MyFolder : MAPIFolder;
35 MyMail, MyReply : _MailItem;
36 MailRecipients, ReplyRecipients : Recipients; // !! Collection !!
37 ARecipient : Recipient; // !! Item !!
38 i, j : Integer;
39 seMailAddress : string;
40 begin
41 MyOutlook := CoOutlookApplication.Create;
42 try
43 MyNameSpace := MyOutlook.GetNamespace('MAPI');
44 MyFolder := MyNameSpace.GetDefaultFolder(olFolderInbox);
45 for i := 1 to MyFolder.Items.Count do
46 begin
47 MyMail := (MyFolder.Items.Item(i) as _MailItem);
48 // Comme nous voulons récupérer l'adresse email réelle de l'expéditeur.
49 // As we want retrieve the real Sender email address.
50 MyReply := MyMail.Reply;
51
52 MailRecipients := MyMail.Recipients;
53 ReplyRecipients := MyReply.Recipients;
54 ListBox3.Items.BeginUpdate;
55 // Récupération de toutes les adresses email réelles des personnes
56 // en copie.
57 // Retrieve ALL CC real email addresses.
58 for j := 1 to MailRecipients.Count do
59 begin
60 ARecipient := MailRecipients.Item(j);
61 seMailAddress := ARecipient.Address;
62 if Pos('@',seMailAddress) > 0 then
63 ListBox3.Items.Append(seMailAddress);
64 end;
65 // Récupération de l'adresse email réelle de l'expéditeur.
66 // Retrieve the real Sender email address.
67 for j := 1 to ReplyRecipients.Count do
68 begin
69 ARecipient := ReplyRecipients.Item(j);
70 seMailAddress := ARecipient.Address;
71 if Pos('@',seMailAddress) > 0 then
72 ListBox3.Items.Append(seMailAddress);
73 end;
74 ListBox3.Items.EndUpdate;
75 end;
76 finally
77 MyOutlook.Quit;
78 end;
79 end;
80
81 end.
|