Ovo je moja procedura. Izvukao sam dijelove koji trebaju (valjda nisam nešto preskočio) jer je napravljena kao zaseban thread u kom se kreira i PDF izvješća koji se šalje.
idS: TIdSMTP;
IdM: TIdMessage;
IdSSLIOHandlerSocketOpenSSL1: TIdSSLIOHandlerSocketOpenSSL;
ToMail: string;
tMyClass.Parametri je moja klasa koja čita iz ini file-a podatke.
Da li verzija indy-a koju koristiš ima veze?
Code:
IdS.Host := tMyClass.Parametri.ParamByName['MAIL_HOST'].AsString;
IdS.IOHandler := IdSSLIOHandlerSocketOpenSSL1;
IdS.UseTLS := utUseRequireTLS;
IdS.Port := tMyClass.Parametri.ParamByName['MAIL_PORT'].AsInteger; //587 ;
IdS.UserName := tMyClass.Parametri.ParamByName['MAIL_USERNAME'].AsString;
IdS.Password := tMyClass.Parametri.ParamByName['MAIL_PASSWORD'].AsString;
// kreiranje prijemnih mail adresa
MaliBr := 1;
while tMyClass.Parametri.SeekParam('MAIL_ADRESA_TO_' + MaliBr.ToString) do begin
if ToMail <> '' then ToMail := ToMail + '; ';
ToMail := ToMail + tMyClass.Parametri.ParamByName['MAIL_ADRESA_TO_' + MaliBr.ToString].AsString;
Inc(MaliBr);
end;
IdM.Clear;
idm.ContentType := 'multipart/related; charset=win-1250';
IdM.Body.Clear;
IdM.Body.Append('Izvješće o prometu na dan: ' + DateTimeToStr(dat));
IdM.Encoding := meMime;
idm.ContentType := 'multipart/text; charset=win-1250';
IdM.From.Name := FirmaIme;
IDM.From.Address := tMyClass.Parametri.ParamByName['Mail_Adresa_From'].AsString;
IdM.Recipients.EMailAddresses := ToMail;
IdM.Subject := 'Izviješče o prometu na dan: ' + DateTimeToStr(Dat);
IdS.Connect;
Attachment := TIdAttachmentfile.Create(Idm.MessageParts,dir);
Attachment.ContentDisposition := 'attachment';
Attachment.ContentType := 'text/xml';
Attachment.FileName := dir;
Attachment1 := TIdAttachmentfile.Create(Idm.MessageParts,rac);
Attachment1.ContentDisposition := 'attachment';
Attachment1.ContentType := 'text/xml';
Attachment1.FileName := Rac;
Attachment2 := TIdAttachmentfile.Create(Idm.MessageParts,Spec);
Attachment2.ContentDisposition := 'attachment';
Attachment2.ContentType := 'text/xml';
Attachment2.FileName := Spec;
IdS.Send(IdM);
Attachment.Free;
Attachment1.Free;
Attachment2.Free;
IdS.Disconnect;
I ovo su property Indy controla:
Code:
object idS: TIdSMTP
IOHandler = IdSSLIOHandlerSocketOpenSSL1
SASLMechanisms = <>
UseTLS = utUseExplicitTLS
Left = 408
Top = 160
end
object IdM: TIdMessage
AttachmentEncoding = 'MIME'
BccList = <>
CharSet = 'windows-1250'
CCList = <>
Encoding = meMIME
FromList = <
item
end>
Recipients = <>
ReplyTo = <>
ConvertPreamble = True
Left = 488
Top = 160
end
object IdSSLIOHandlerSocketOpenSSL1: TIdSSLIOHandlerSocketOpenSSL
Destination = ':25'
MaxLineAction = maException
Port = 25
DefaultPort = 0
SSLOptions.Mode = sslmUnassigned
SSLOptions.VerifyMode = []
SSLOptions.VerifyDepth = 0
Left = 536
Top = 264
end