var
outlook, ns, folder, appointment, prop: OLEVariant;
const olFolderCalendar = $00000009;
olText = 1;
begin
{initialize an Outlook}
outlook := CreateOLEObject('Outlook.Application');
{get
MAPI namespace}
ns := outlook.GetNamespace('
MAPI');
{get a default Contacts folder}
folder := ns.GetDefaultFolder(olFolderCalendar);
{if Contacts folder is found}
if not VarIsNull(folder) then
begin
try
appointment := folder.Items.Find('[GC-ID]=''1004''');
except
end;
if varType(Appointment)=varNull) or
(varType(Appointment)=varEmpty) then
begin
showMessage('NEW');
{create a new item}
appointment := folder.Items.Add(olAppointmentItem);
prop := appointment.UserProperties.Add('GC-ID',olText,True);
prop.Value := '''1004''';
{define a subject and body of appointment}
appointment.Subject := 'new appointment';
appointment.Body := 'call me tomorrow';
{duration: 10 days starting from today}
appointment.Start := Now();
appointment.End := Now()+10; {10 days for execution}
appointment.AllDayEvent := 1; {all day event}
{set reminder in 20 minutes}
appointment.ReminderMinutesBeforeStart := 20;
appointment.ReminderSet := 1;
{set a high priority}
appointment.Importance := olImportanceHigh;
{to save an appointment}
appointment.Save;