procedure TForm1.Button1Click(Sender: TObject);
var lNameSpace : NameSpace;
lFolder : MAPIFolder;
lItemColl : Items;
i, j : Integer;
lElement : OleVariant;
lContact : ContactItem;
FlagIcon : integer;
Body :
string;
FlagStatus : integer;
ReminderTime : TDateTime;
AListItem : TListItem;
AReceiver :
String;
begin
try
try
OutlookApplication1.Connect;
lNameSpace := OutlookApplication1.GetNamespace('
MAPI');
lFolder := lNamespace.PickFolder;
lItemColl := lFolder.Items;
Listview1.Clear;
IF lItemColl.Count > 0
THEN
BEGIN
FOR i := 1
to lItemColl.Count
do
BEGIN
lElement := lItemColl.item(i);
FlagIcon := lElement.FlagIcon;
Body := lElement.Subject;
FlagStatus := lElement.FlagStatus;
ReminderTime := lElement.ReminderTime;
AReceiver := lElement.
to;
// <-------- Hier steigt das Programm aus
FlagIcon := lElement.FlagIcon;
FlagStatus := lElement.FlagStatus;
If ReminderTime <= Now()
then
begin
if FlagIcon <> 0
then
begin
if FlagStatus = olFlagMarked
then
begin
AListItem := ListView1.Items.Add;
AListItem.Caption := Body;
// Object
AListItem.SubItems.Add(DateTimeToStr(ReminderTime));
//Reminder
AListItem.SubItems.Add(AReceiver);
//AReceiver
end;
end;
end;
END;
END;
except
on e: SysUtils.Exception
do ShowMessage(e.
Message);
end;
finally
OutlookApplication1.Disconnect;
end;
end;