uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, IdPOP3, IdBaseComponent, IdComponent, IdTCPConnection,
IdTCPClient, IdExplicitTLSClientServerBase, IdMessageClient, IdSMTPBase,
IdSMTP, StdCtrls, ComCtrls, Grids, IdMessage, IdIOHandler, IdCoder3to4,
IdIOHandlerSocket, IdIOHandlerStack, IdSSL, IdSSLOpenSSL, IdSASLLogin,
IdSASLExternal, IdUserPassProvider, IdSASL_CRAM_MD5, IdSASL_CRAM_SHA1,
IdSASLPlain, IdSASLSKey, IdSASLOTP, IdSASLAnonymous, IdAttachment, IdGlobal,
IdSASLUserPass, IdSASLDigest, IdText, IdCoderMIME, IdCoder,
IdAttachmentFile, IdAttachmentMemory;
type
TCalendarData =
class
cdHost:
string;
//Strato: smtp.strato.de
cdAccount:
string;
//Mr. T's Mailaccount
cdPort: integer;
//Strato: 465 or 587
cdUseTLS: integer;
cdSSLConnection: boolean;
//Strato: True
cdTransferEmail:
string;
//Strato: you@youraccout.de
cdUser:
string;
//Strato: you@youraccout.de
cdPass:
string;
//Strato: Strato Password
cdOrganizer:
string;
//Organisator
cdAttendee:
string;
//Empfänger
cdAppointmentStart: TDateTime;
//Anfang Termin
cdAppointmentEnd: TDateTime;
//Ende Termin
cdSummary:
string;
//Betreff
cdLocation:
string;
//Ort
cdBody: TStringList;
//Body
cdDescription:
string;
//Beschreibung
cdPriority: TIdMessagePriority;
//Prioriät
constructor Create;
destructor Destroy;
override;
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
constructor TCalendarData.Create;
begin
inherited;
cdBody := TStringList.Create;
end;
destructor TCalendarData.Destroy;
begin
cdBody.Free;
inherited;
end;
procedure SendCalendarRequest(CD: TCalendarData);
var
IdMessage: TIdMessage;
SMTP: TIdSMTP;
SSLHandler: TIdSSLIOHandlerSocketOpenSSL;
IdUserPassProvider: TIdUserPassProvider;
IdSASLCRAMMD5: TIdSASLCRAMMD5;
IdSASLCRAMSHA1: TIdSASLCRAMSHA1;
IdSASLPlain: TIdSASLPlain;
IdSASLLogin: TIdSASLLogin;
IdSASLSKey: TIdSASLSKey;
IdSASLOTP: TIdSASLOTP;
IdSASLAnonymous: TIdSASLAnonymous;
IdSASLExternal: TIdSASLExternal;
MemoryStream: TMemoryStream;
Attachment: TIdAttachment;
begin
MemoryStream := TMemoryStream.Create();
IdMessage := TIdMessage.Create(
nil);
try
with IdMessage, cd
do
begin
AttachmentEncoding := '
mime';
ContentTransferEncoding := '
base64';
//ContentTransferEncoding := '7-bit';
Encoding := meMIME;
ContentType := '
text/html';
Charset := '
utf-8';
From.
Name := cdAccount;
From.Address := cdOrganizer;
Recipients.EMailAddresses := cdAttendee;
Priority := cdPriority;
Body.Text := '
';
//Body.AddStrings(cd.cdBody);
Attachment.ContentType:='
text/calendar';
//set the content type to text/calendar
// Attachment := TIdAttachment.Create(IdMessage.MessageParts, cdBody.ToString);
end;
//with IdMessage, md
SMTP := TIdSMTP.Create(
nil);
try
if 1=1
then //CD.edSSLConnection
begin
SSLHandler := TIdSSLIOHandlerSocketOpenSSL.Create(
SMTP);
with SSLHandler
do
begin
MaxLineAction := maException;
SSLOptions.Method := sslvTLSv1;
SSLOptions.Mode := sslmClient;
SSLOptions.VerifyMode := [];
SSLOptions.VerifyDepth := 0;
end;
//with SSLHandler
SMTP.IOHandler := SSLHandler;
SMTP.UseTLS := utUseImplicitTLS;
//utUseExplicitTLS;
end;
if (cd.cdUser <> '
')
or (cd.cdPass <> '
')
then
begin
SMTP.AuthType := satSASL;
IdUserPassProvider := TIdUserPassProvider.Create(
SMTP);
IdUserPassProvider.Username := cd.cdUser;
IdUserPassProvider.Password:= cd.cdPass;
IdSASLCRAMSHA1 := TIdSASLCRAMSHA1.Create(
SMTP);
IdSASLCRAMSHA1.UserPassProvider := IdUserPassProvider;
IdSASLCRAMMD5 := TIdSASLCRAMMD5.Create(
SMTP);
IdSASLCRAMMD5.UserPassProvider := IdUserPassProvider;
IdSASLSKey := TIdSASLSKey.Create(
SMTP);
IdSASLSKey.UserPassProvider := IdUserPassProvider;
IdSASLOTP := TIdSASLOTP.Create(
SMTP);
IdSASLOTP.UserPassProvider := IdUserPassProvider;
IdSASLAnonymous := TIdSASLAnonymous.Create(
SMTP);
IdSASLExternal := TIdSASLExternal.Create(
SMTP);
IdSASLLogin := TIdSASLLogin.Create(
SMTP);
IdSASLLogin.UserPassProvider := IdUserPassProvider;
IdSASLPlain := TIdSASLPlain.Create(
SMTP);
IdSASLPlain.UserPassProvider := IdUserPassProvider;
SMTP.SASLMechanisms.Add.SASL := IdSASLCRAMSHA1;
SMTP.SASLMechanisms.Add.SASL := IdSASLCRAMMD5;
SMTP.SASLMechanisms.Add.SASL := IdSASLSKey;
SMTP.SASLMechanisms.Add.SASL := IdSASLOTP;
SMTP.SASLMechanisms.Add.SASL := IdSASLAnonymous;
SMTP.SASLMechanisms.Add.SASL := IdSASLExternal;
SMTP.SASLMechanisms.Add.SASL := IdSASLLogin;
SMTP.SASLMechanisms.Add.SASL := IdSASLPlain;
end
else
begin
SMTP.AuthType := satNone;
end;
SMTP.Host := cd.cdHost;
SMTP.Port := cd.cdPort;
SMTP.ConnectTimeout := 30000;
SMTP.UseEHLO := True;
SMTP.Connect;
try
SMTP.Send(IdMessage);
finally
SMTP.Disconnect;
end;
//try..finally
finally
SMTP.Free;
end;
//try..finally
finally
MemoryStream.Free;
IdMessage.Free;
end;
//try..finally
end;
//SendCalendarRequest
begin
//Sende Besprechungseinladungen
cd := TCalendarData.Create();
with cd
do
begin
cdHost := Edit3.Text;
cdAccount := '
Auto Calendar';
//Mr. T's Mailaccount
cdPort := StrToInt(Edit6.Text);
//Strato: 465 or 587
cdUseTLS := Combobox1.ItemIndex;
cdSSLConnection := True;
//Strato: True
cdTransferEmail := Edit2.Text;
//Strato: you@youraccout.de
cdUser := Edit4.Text;
//Strato: you@youraccout.de
cdPass := Edit5.Text;
//Strato: Strato Passwort
cdOrganizer := '
calendar@xyz.de';
//Organisator
cdAttendee := '
empfaenger@xyz.de';
//Empfänger
cdAppointmentStart := Now;
//Anfang Termin
cdAppointmentEnd := Now+0.1;
//Ende Termin
cdSummary := '
Besprechung Meier (wwewe)';
//Betreff
cdLocation := '
Büro XY';
//Ort
cdDescription := '
Dies ist ein Text;';
//Beschreibung
cdPriority := mpNormal;
//Prioriät
with cdBody
do
begin
Add('
BEGIN:VCALENDAR');
Add('
VERSION:1.0');
Add('
BEGIN:VEVENT');
Add('
ATTENDEE:' + cdAttendee);
Add('
ORGANIZER:MAILTO:' + cdOrganizer);
Add('
DTStart:' + FormatDateTime('
YYYYMMDD', cdAppointmentStart) + '
T' + FormatDateTime('
HHMMSS', cdAppointmentStart) + '
Z');
Add('
DTEnd:' + FormatDateTime('
YYYYMMDD', cdAppointmentEnd) + '
T' + FormatDateTime('
HHMMSS', cdAppointmentEnd) + '
Z');
Add('
LOCATION:' + cdLocation);
Add('
UID:LeanCredit.de');
Add('
SUMMARY:' + cdSummary);
Add('
DESCRIPTION:' + cdDescription);
Add('
PRIORITY:5');
Add('
END:VEVENT');
Add('
END:VCALENDAR');
end;
//cdBody
end;
//cd
SendCalendarRequest(cd);
end.