1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
| procedure TFMaintenance.actEnvoyerExecute(Sender: TObject);
var iPos : integer ;
domaine : string ;
email : string ;
SSLHandler : TIdSSLIOHandlerSocketOpenSSL ;
pwd : string ;
numero : string ;
myText : TIdTExt ;
myAttachment : TIdAttachmentFile ;
begin
bSend := true ;
//On envoie le contenu au développeur//
email := '' ;
email := IBTUtilisateur.Lookup('ID',FDmKSF.idUser,'MAIL') ;
pwd := '' ;
pwd := IBTUtilisateur.Lookup('ID',FDmKSF.idUser,'MOT_DE_PASSE') ;
iPos := pos('@',email) ;
domaine := copy(email,iPos+1,length(email)) ;
//Correspondances//
if domaine = 'hotmail.fr' then domaine := 'live.fr' ;
SSLHandler := TIdSSLIOHandlerSocketOpenSSL.create(nil) ;
try
try
SSLHandler.MaxLineAction := maException ;
SSLHandler.SSLOptions.Method := sslvTLSv1 ;
SSLHandler.SSLOptions.Mode := sslmUnassigned ;
SSLHandler.SSLOptions.VerifyMode := [] ;
SSLHandler.SSLOptions.VerifyDepth := 0 ;
IdSMTP1.IOHandler := SSLHandler ;
IdSMTP1.Host := 'smtp.' + domaine ;
IdSMTP1.Port := 587 ;
IdSMTP1.Username := email ;
IdSMTP1.Password := pwd ;
IdSMTP1.UseTLS := utUseExplicitTLS ;
IdMessage1.Encoding := meMIME;
IdMessage1.ContentType := 'multipart/mixed';
IdMessage1.From.Address := email ;
IdMessage1.Recipients.Add.Address := 'xxxx_xxxx@hotmail.fr' ;
IdMessage1.Subject := 'test' ;
IdMessage1.UseNowForDate := true;
{Ajout du texte}
myText := TIdText.Create(IdMessage1.MessageParts);
myText.Body.Assign(RichEdit1.Lines);
myText.ContentType := 'text/plain';
myText.CharSet := 'ISO-8859-1';
myText.ContentTransfer := '8bit';
if CheckBox1.Checked then
begin
actRealiserBackup.Execute ;
end ;
{Ajout de la pièce jointe}
myAttachment := TIdAttachmentFile.Create(IdMessage1.MessageParts,back);
myAttachment.ContentType := 'text/html';
myAttachment.ContentDisposition := 'attachment';
myAttachment.FileName := ExtractFileName(back);
IdSMTP1.Connect ;
IdSMTP1.Send(idMessage1);
IdSMTP1.Disconnect;
Dialogs.MessageDlg('Le mail a bien été envoyé au service client.', mtInformation,
[mbOk], 0, mbOk)
finally
SSLHandler.Free ;
IdMessage1.MessageParts.Clear ;
end;
except on E:Exception do
try
IdSMTP1.Port := 25 ;
IdSMTP1.Connect ;
IdSMTP1.Send(idMessage1);
IdSMTP1.Disconnect;
Dialogs.MessageDlg('Le mail a bien été envoyé au service client.', mtInformation,
[mbOk], 0, mbOk)
except
Dialogs.MessageDlg('Une erreur est survenue lors de l''envoi. Veuillez vérifier votre connexion à Internet.', mtError,
[mbOk], 0, mbOk) ;
end;
end;
end ; |
Partager