L'envoi d'e-mails HTML avec ics
procédure THtmlMailForm.SendButtonClick(Sender: TObject)
begin
si FRunning puis commencer
MessageBeep(MB_OK)
Display ('**** DÉJÀ en cours d'EXÉCUTION ****')
Sortie
fin
FRunning := TRUE
{ Donner le composant les différentes données dont il a besoin }
HtmlSmtpClient.En Clair := PlainTextMemo.Lignes
HtmlSmtpClient.HtmlText := HtmlTextMemo.Lignes
HtmlSmtpClient.EmailImages := ImageFilesMemo.Lignes
HtmlSmtpClient.EmailFiles := AttachedFilesMemo.Lignes
{ Initialiser tous les SMTP des propriétés du composant à partir de notre interface graphique }
HtmlSmtpClient.Hôte := HostEdit.Texte
HtmlSmtpClient.Port := PortEdit.Texte
HtmlSmtpClient.SignOn := SignOnEdit.Texte
HtmlSmtpClient.FromName := FromEdit.Texte
HtmlSmtpClient.HdrFrom := FromEdit.Texte
HtmlSmtpClient.HdrTo := ToEdit.Texte
HtmlSmtpClient.HdrCc := CcEdit.Texte
HtmlSmtpClient.HdrSubject := SubjectEdit.Texte
HtmlSmtpClient.AuthType := smtpAuthNone
{ liste des Destinataires est calculée à partir De, champs Cc et Cci }
HtmlSmtpClient.RcptName.Clair
HtmlSmtpClient.RcptNameAdd(ToEdit.Texte, CcEdit.Texte, BccEdit.texte)
si PlainTextCheckBox.Cette option est cochée,
HtmlSmtpClient.ContentType := smtpPlainText
else
HtmlSmtpClient.ContentType := smtpHtml
Display('la Connexion au serveur SMTP...')
{ Début de la première opération à faire pour envoyer un e-mail }
{ Prochaines opérations sont lancées à partir OnRequestDone événement }
HtmlSmtpClient.Se connecter
sauf
E:Exception do begin
Affichage(E. ClassName ': 'E. Message)
FRunning := FALSE
fin
fin
fin
{* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}
procédure THtmlMailForm.HtmlSmtpClientRequestDone(
Sender : TObject
RqType : TSmtpRequest
ErrorCode : Word)
begin
{ Pour chaque opération, on affiche le statut }
if (ErrorCode > 0) et (ErrorCode < 10000)
Display('RequestDone Rq=' IntToStr(Ord(RqType))
' Erreur=' HtmlSmtpClient.ErrorMessage)
else
Display('RequestDone Rq=' IntToStr(Ord(RqType))
' Erreur=' IntToStr(ErrorCode))
si non FRunning puis
Sortie
{ Début de la prochaine opération, mais d'abord vérifier si le précédent était OK }
si le code d'erreur <> 0 then begin
FRunning := FALSE { Résilier Tout-En-Un démo }
Display('Erreur, s'arrêter.')
Sortie
fin
cas RqType de
smtpConnect: commencer
si HtmlSmtpClient.AuthType = smtpAuthNone puis
HtmlSmtpClient.Helo
else
HtmlSmtpClient.Ehlo
fin
smtpHelo: HtmlSmtpClient.MailFrom
smtpEhlo: HtmlSmtpClient.Auth
smtpAuth: HtmlSmtpClient.MailFrom
smtpMailFrom: HtmlSmtpClient.RcptTo
smtpRcptTo: HtmlSmtpClient.Les données
smtpData: HtmlSmtpClient.Quittez
smtpQuit: commencer
Display ('!')
FRunning := FALSE
fin
fin
fin
L'envoi d'e-mails HTML avec ics
L'envoi d'e-mails HTML avec ics : Plusieurs milliers de conseils pour vous faciliter la vie.
procedure THtmlMailForm.SendButtonClick(Sender: TObject)
begin
si FRunning puis commencer
MessageBeep(MB_OK)
Display ('**** DEJA en cours d'EXECUTION ****')
Sortie
fin
FRunning := TRUE
{ Donner le composant les differentes donnees dont il a besoin }
HtmlSmtpClient.En Clair := PlainTextMemo.Lignes
HtmlSmtpClient.HtmlText := HtmlTextMemo.Lignes
HtmlSmtpClient.EmailImages := ImageFilesMemo.Lignes
HtmlSmtpClient.EmailFiles := AttachedFilesMemo.Lignes
{ Initialiser tous les SMTP des proprietes du composant a partir de notre interface graphique }
HtmlSmtpClient.Hote := HostEdit.Texte
HtmlSmtpClient.Port := PortEdit.Texte
HtmlSmtpClient.SignOn := SignOnEdit.Texte
HtmlSmtpClient.FromName := FromEdit.Texte
HtmlSmtpClient.HdrFrom := FromEdit.Texte
HtmlSmtpClient.HdrTo := ToEdit.Texte
HtmlSmtpClient.HdrCc := CcEdit.Texte
HtmlSmtpClient.HdrSubject := SubjectEdit.Texte
HtmlSmtpClient.AuthType := smtpAuthNone
{ liste des Destinataires est calculee a partir De, champs Cc et Cci }
HtmlSmtpClient.RcptName.Clair
HtmlSmtpClient.RcptNameAdd(ToEdit.Texte, CcEdit.Texte, BccEdit.texte)
si PlainTextCheckBox.Cette option est cochee,
HtmlSmtpClient.ContentType := smtpPlainText
else
HtmlSmtpClient.ContentType := smtpHtml
Display('la Connexion au serveur SMTP...')
{ Debut de la premiere operation a faire pour envoyer un e-mail }
{ Prochaines operations sont lancees a partir OnRequestDone evenement }
HtmlSmtpClient.Se connecter
sauf
E:Exception do begin
Affichage(E. ClassName ': 'E. Message)
FRunning := FALSE
fin
fin
fin
{* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}
procedure THtmlMailForm.HtmlSmtpClientRequestDone(
Sender : TObject
RqType : TSmtpRequest
ErrorCode : Word)
begin
{ Pour chaque operation, on affiche le statut }
if (ErrorCode > 0) et (ErrorCode < 10000)
Display('RequestDone Rq=' IntToStr(Ord(RqType))
' Erreur=' HtmlSmtpClient.ErrorMessage)
else
Display('RequestDone Rq=' IntToStr(Ord(RqType))
' Erreur=' IntToStr(ErrorCode))
si non FRunning puis
Sortie
{ Debut de la prochaine operation, mais d'abord verifier si le precedent etait OK }
si le code d'erreur <> 0 then begin
FRunning := FALSE { Resilier Tout-En-Un demo }
Display('Erreur, s'arreter.')
Sortie
fin
cas RqType de
smtpConnect: commencer
si HtmlSmtpClient.AuthType = smtpAuthNone puis
HtmlSmtpClient.Helo
else
HtmlSmtpClient.Ehlo
fin
smtpHelo: HtmlSmtpClient.MailFrom
smtpEhlo: HtmlSmtpClient.Auth
smtpAuth: HtmlSmtpClient.MailFrom
smtpMailFrom: HtmlSmtpClient.RcptTo
smtpRcptTo: HtmlSmtpClient.Les donnees
smtpData: HtmlSmtpClient.Quittez
smtpQuit: commencer
Display ('!')
FRunning := FALSE
fin
fin
fin
L'envoi d'e-mails HTML avec ics
By commentfaire
L'envoi d'e-mails HTML avec ics : Plusieurs milliers de conseils pour vous faciliter la vie.