bei uns auf der Arbeit gibt es mehr oder weniger "suboptimale" Prozesse, wenn es darum geht den Urlaub / Gleitzeit / mobiles Arbeiten zu beantragen. Hierzu müssen wir ettliche sich widerhohlende langweilige Aufgaben in Outlook erledigen.
Also dachte ich mir bastle ich mir ein Lazarusprogram das das für mich erledigt. Einiges an Google Suche später und es stellt sich heraus, das geht ist aber sehr mühseelig (zumindest wie ich das bisher hin bekomme) und daher hier die Frage ob ihr mir einen Tipp geben könnt, wie ich das effizienter hin bekomme.
Gestartet bin ich mit:
https://forum.lazarus.freepascal.org/in ... ic=18931.0
und
https://docs.microsoft.com/de-de/office ... ntmentitem
Dann habe ich mir folgende Unit gebastelt:
Code: Alles auswählen
Unit uOutlook;
{$MODE ObjFPC}{$H+}
Interface
Uses
Classes, SysUtils, ComObj;
(*
* MSDN: https://docs.microsoft.com/de-de/office/vba/api/overview/outlook/object-model
*
*)
Const
olMailItem = 0; // https://forum.lazarus.freepascal.org/index.php?topic=18931.0
olAppointmentItem = 1; // Durch Try and Error ermittelt
olContactItem = 2; // Durch Try and Error ermittelt
// olMeeting = 0; -- Das stimmt noch nicht
Procedure DisplayOutlookItem(Item: integer); // Zum Ermillten der olMailItem , ...
Procedure NewAppointMent(Subject: String);
Procedure SendMail(CC, BCC, Subject, Body: String; Send: Boolean);
Implementation
Procedure DisplayOutlookItem(Item: integer);
Var
Outlook: OLEVariant;
newAppointment: OLEVariant;
Begin
Try
Outlook := GetActiveOleObject('Outlook.Application');
Except
Outlook := CreateOleObject('Outlook.Application');
End;
newAppointment := Outlook.CreateItem(Item);
newAppointment.Display;
Outlook := Unassigned;
End;
// https://docs.microsoft.com/de-de/office/vba/api/outlook.appointmentitem
Procedure NewAppointMent(Subject: String);
Var
Outlook: OLEVariant;
newAppointment: OLEVariant;
tmp: variant;
Begin
Try
Outlook := GetActiveOleObject('Outlook.Application');
Except
Outlook := CreateOleObject('Outlook.Application');
End;
newAppointment := Outlook.CreateItem(olAppointmentItem);
newAppointment.MeetingStatus := 1;
tmp := Subject;
newAppointment.Subject := tmp;
newAppointment.Display;
Outlook := Unassigned;
End;
// Quelle: https://forum.lazarus.freepascal.org/index.php?topic=18931.0
Procedure SendMail(CC, BCC, Subject, Body: String; Send: Boolean);
Var
Outlook: OLEVariant;
MailItem: variant;
tmp: variant;
Begin
Try
Outlook := GetActiveOleObject('Outlook.Application');
Except
Outlook := CreateOleObject('Outlook.Application');
End;
MailItem := Outlook.CreateItem(olMailItem);
// TODO: Wie kriegen wir das "AN" ?
If cc <> '' Then Begin
tmp := CC;
MailItem.to := tmp; // das geht net weil to ein schlüsselwort ist :(
End;
If cc <> '' Then Begin
tmp := CC;
MailItem.Cc := tmp;
End;
If bcc <> '' Then Begin
tmp := BCC;
MailItem.BCC := tmp;
End;
If Subject <> '' Then Begin
tmp := Subject;
MailItem.Subject := tmp;
End;
If Body <> '' Then Begin
tmp := Body;
MailItem.Body := tmp;
End;
// MailItem.HTMLBody // if you wont HTML in message body
// tmp := AttachEdit.Text;
// MailItem.Attachments.Add(tmp);
If send Then Begin
MailItem.Send;
End
Else Begin
MailItem.Display;
End;
Outlook := Unassigned;
End;
End.
Auch die Constanten sind alle via Try and Error ermittelt. Code Vervollständigung gibt es hier nicht

Ich habe leider nirgends eine Dokumentation dieser Constanten gefunden, habt ihr da bessere Quellen ? Ne Idee wie ich den Try and Error Process verringern kann ?
Mein Ziel ist es:
- Termine zu bearbeiten, versenden und deren Anzeige zu verändern