Activex OLE Delphi

unit UMain;
interface
//If you are using Delphi 6 or greater replace OutLook_TLB with Outlook2000
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ComObj, Outlook_TLB, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
ListBox3: TListBox;
Label1: TLabel;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.Button1Click(Sender: TObject);
var
MyOutlook : _Application;
MyNameSpace : _NameSpace;
MyFolder : MAPIFolder;
MyMail, MyReply : _MailItem;
MailRecipients, ReplyRecipients : Recipients; // !! Collection !!
ARecipient : Recipient; // !! Item !!
i, j : Integer;
seMailAddress : string;
begin
MyOutlook := CoOutlookApplication.Create;
try
MyNameSpace := MyOutlook.GetNamespace('MAPI');
MyFolder := MyNameSpace.GetDefaultFolder(olFolderInbox);
for i := 1 to MyFolder.Items.Count do
begin
MyMail := (MyFolder.Items.Item(i) as _MailItem);
// Comme nous voulons récupérer l'adresse email réelle de l'expéditeur.
// As we want retrieve the real Sender email address.
MyReply := MyMail.Reply;
MailRecipients := MyMail.Recipients;
ReplyRecipients := MyReply.Recipients;
ListBox3.Items.BeginUpdate;
// Récupération de toutes les adresses email réelles des personnes
// en copie.
// Retrieve ALL CC real email addresses.
for j := 1 to MailRecipients.Count do
begin
ARecipient := MailRecipients.Item(j);
seMailAddress := ARecipient.Address;
if Pos('@',seMailAddress) > 0 then
ListBox3.Items.Append(seMailAddress);
end;
// Récupération de l'adresse email réelle de l'expéditeur.
// Retrieve the real Sender email address.
for j := 1 to ReplyRecipients.Count do
begin
ARecipient := ReplyRecipients.Item(j);
seMailAddress := ARecipient.Address;
if Pos('@',seMailAddress) > 0 then
ListBox3.Items.Append(seMailAddress);
end;
ListBox3.Items.EndUpdate;
end;
finally
MyOutlook.Quit;
end;
end;
end.