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
| unit Unit1;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, IdContext, IdComponent,
IdCustomTCPServer, IdTCPServer, IdCmdTCPServer, IdExplicitTLSClientServerBase,
IdSMTPServer, IdBaseComponent, IdMessage, IdTCPConnection, IdTCPClient,
IdMessageClient, IdSMTPBase, IdSMTP ;
type
TForm1 = class(TForm)
Label1: TLabel;
Label2: TLabel;
Edit1: TEdit;
Edit2: TEdit;
Button1: TButton;
Memo1: TMemo;
Label3: TLabel;
Button2: TButton;
Button3: TButton;
sujet: TLabel;
Edit3: TEdit;
OpenDialog1: TOpenDialog;
IdMessage1: TIdMessage;
IdSMTP1: TIdSMTP;
Edit4: TEdit;
Label5: TLabel;
Edit6: TEdit;
procedure Button3Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Déclarations privées }
public
{ Déclarations publiques }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
idMessage1.From.Text :=Edit1.Text; //Adresse email de l'expediteur
IdMessage1.Recipients.EMailAddresses:=Edit2.Text; //Adresse email du destinataire
IdMessage1.Subject:=edit3.Text; //Sujet du message
IdMessage1.Body.text:=Memo1.Lines.Text; //Corps du message
IdSMTP1.Username:=edit1.Text;
IdSMTP1.Password:=Edit6.Text;
IdSMTP1.Host :='smtp.live.com';
IdSMTP1.Port := 25;
IdSMTP1.Connect;
try
IdSMTP1.Send(IdMessage1); //Envoi du message
showmessage('message envoyé');
application.Terminate;
finally
IdSMTP1.Disconnect; //Déconnexion
end;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
if OpenDialog1.Execute then
Edit4.Text := OpenDialog1.FileName;
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
close;
end;
end. |
Partager