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
|
var
IdMessage: TIdMessage;
IdSMTP: TIdSMTP;
Message: TStrings;
begin
IdMessage := TIdMessage.Create(nil);
IdMessage.From.Address := 'nom@serveur.com';
IdMessage.ReplyTo.Add.Address := 'nom@serveur.com';
IdMessage.Recipients.Add.Address := 'nom1@yahoo.fr';
IdMessage.Recipients.Add.Address := 'nom2@gmail.com';
IdMessage.Recipients.Add.Address := 'nom3@hotmail.fr';
IdMessage.Subject := 'Message HTML test via Delphi';
IdMessage.ContentType := 'multipart/alternative';
Message := Memo.Lines;
With TIdText.Create(IdMessage.MessageParts, Message) Do
Begin
ContentType := 'text/plain';
Body.Insert(0, 'Ceci est un Message HTML. Configurez votre Client de Messagerie pour le visionner correctement.');
end;
with TIdText.Create(IdMessage.MessageParts, Message) do
ContentType := 'text/html';
IdSMTP := TIdSMTP.Create(nil) ;
IdSMTP.Port := 25;
IdSMTP.Host := 'mail.serveur.com';
IdSMTP.Username:='nom@serveur.com';
IdSMTP.Password:='mot_de_passe';
Try
Try
IdSMTP.Connect;
IdSMTP.Send(IdMessage);
except
on e: exception do MessageDlg(e.Message, mtError, [mbOK], 0);
end;
finally
IdSMTP.Disconnect;
IdSMTP.Free;
IdMessage.Free;
end;
end ; |
Partager