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
| unit MainUnit;
// Berlin 10.1
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants,
System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, IdMessage,
IdBaseComponent, IdComponent, IdTCPConnection, IdTCPClient,
IdExplicitTLSClientServerBase, IdMessageClient, IdSMTPBase, IdSMTP,
IdServerIOHandler, IdSSL, IdSSLOpenSSL, IdIOHandler, IdIOHandlerSocket,
IdIOHandlerStack;
type
TForm8 = class(TForm)
Button1: TButton;
IdSMTP1: TIdSMTP;
IdMessage1: TIdMessage;
Serveur: TEdit;
Port: TEdit;
Utilisateur: TEdit;
PassWord: TEdit;
TLS: TCheckBox;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
IdSSLIOHandlerSocketOpenSSL1: TIdSSLIOHandlerSocketOpenSSL;
procedure Button1Click(Sender: TObject);
private
{ Déclarations privées }
public
{ Déclarations publiques }
end;
var
Form8: TForm8;
implementation
{$R *.dfm}
procedure TForm8.Button1Click(Sender: TObject);
begin
idSMTP1.Host:=Serveur.Text;
idSMTP1.Username:=Utilisateur.Text;
idSMTP1.Password:=PassWord.Text;
idSmtp1.Port:=StrToIntDef(port.Text,25);
if TLS.Checked then idSmtp1.UseTLS:=utUseImplicitTLS
else idSmtp1.UseTLS:=utNoTLSSupport;
try
try
idSMTP1.Connect;
idSMTP1.Send(Idmessage1);
showmessage('envoyé');
except
on E:Exception do
Showmessage(E.Message);
end;
finally
idSMTP1.Disconnect;
end;
end;
end. |
Partager