procedure CreateOutlookTaskItem(aStart, aDueDate, aReminderTime: TDateTime;
aSubject, aBody:
string; aReminder: boolean);
var
lNamespace, lOutlook, lFolder, lItem: OleVariant;
begin
try
loutlook := getactiveoleobject('
outlook.application');
except
try
loutlook := createoleObject('
outlook.application');
except
exit;
end;
end;
try
lNamespace := lOutlook.getnamespace('
MAPI');
lNamespace.Logon(EmptyParam, EmptyParam, False, True);
lFolder := lNamespace.getdefaultfolder(13);
lItem := lOutlook.createitem(3);
lItem.StartDate := aStart;
lItem.Subject := aSubject;
lItem.Body := aBody;
if (aDueDate <> 0)
then
lItem.DueDate := aDueDate;
lItem.Categories := '
test';
if (aReminder)
then
begin
lItem.ReminderTime := DateTimeToStr(aReminderTime);
lItem.ReminderSet := true;
end
else
lItem.ReminderSet := false;
lItem.Save;
lNamespace.Logoff;
lItem := unassigned;
finally
lOutlook := unassigned;
end;
end;