Navigation Menu Search PhysiologyWeb
PhysiologyWeb Logo Search PhysiologyWeb
   
— share —
Share on Facebook    Share on X    Share on LinkedIn    Share on Pinterest    Share on Reddit    Email    Copy URL
procedure TForm1.UseDelphiToCreateMicrosoftOutlookAppointmentItem(Sender: TObject);
var
OutlookApplication, OutlookAppointmentItem: Variant;
begin
//be sure ComObj and Variants units are included in the "uses" clause

OutlookApplication := Null;
OutlookAppointmentItem := Null;

try
//create Outlook OLE
OutlookApplication := CreateOleObject('Outlook.Application');
except
OutlookApplication := Null;
//add error/exception handling code as desired
end;

If VarIsNull(OutlookApplication) = False then
begin
try
//Create Outlook Appointment Item
try
OutlookAppointmentItem := OutlookApplication.CreateItem(1); //olAppointmentItem = $00000001
//reference
//https://docs.microsoft.com/en-us/office/vba/api/outlook.appointmentitem
except
OutlookAppointmentItem := Null;
//add error/exception handling code as desired
end;

If VarIsNull(OutlookAppointmentItem) = False then
begin
OutlookAppointmentItem.Subject := 'Outlook Calendar Appointment';
OutlookAppointmentItem.Body := 'This Microsoft Outlook calendar appointment was created programmatically by Delphi!';
OutlookAppointmentItem.Location := 'My office';
OutlookAppointmentItem.AllDayEvent := False;
OutlookAppointmentItem.Start := EncodeDateTime(2022, 8, 7, 9, 0, 0, 0);
OutlookAppointmentItem.End := EncodeDateTime(2022, 8, 7, 9, 50, 0, 0);
OutlookAppointmentItem.Save;
//reference
//https://docs.microsoft.com/en-us/office/vba/api/outlook.appointmentitem
end;
finally
OutlookAppointmentItem := Unassigned;
OutlookApplication := Unassigned;
end;
end;
end;




Posted: Saturday, August 6, 2022
Last updated: Tuesday, March 18, 2025
— share —
Share on Facebook    Share on X    Share on LinkedIn    Share on Pinterest    Share on Reddit    Email    Copy URL