unit Unit7;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, Buttons, IdBaseComponent, IdComponent,
  IdTCPConnection, IdTCPClient, IdMessageClient, IdSMTP,idmessage,shellapi,PRINTERS;

type
  TForm7 = class(TForm)
    Memo1: TMemo;
    BitBtn1: TBitBtn;
    Button1: TButton;
    Button2: TButton;
    procedure BitBtn1Click(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form7: TForm7;

implementation

uses Unit4, Unit2;

{$R *.dfm}

procedure TForm7.BitBtn1Click(Sender: TObject);
begin
memo1.Clear;
form7.Close;
form4.close;
end;

procedure TForm7.Button1Click(Sender: TObject);
var msg:TIdMessage;
Message,Message1:string;
begin
Message := 'mailto:someone@somewhere.com'
    + '?subject=This is the subjectBehold Error Report'
    + '&body=This is line 1' + '%0D%0A'
    + 'This is line 2' + '%0D%0A'
    + 'This is line 3'
    + '&Attach=c:\file1.txt';
//    Message1 := 'mailto:someone@somewhere.com';
//  RetVal := ShellExecute(Handle, 'open', PChar(Message), nil, nil, SW_SHOWNORMAL);
ShellExecute(0, 'open', PChar(Message), nil, nil, SW_SHOWNORMAL);
//  WinExec(PChar(Message1), SW_SHOWNORMAL);
//  if RetVal <= 32 then
//     MessageDlg('Cannot find program to send e-mail.', mtWarning, [mbOK], 0);

// NMSMTP1.Host   := 'mail.host.com';
//   NMSMTP1.UserID := 'Username';
//   NMSMTP1.Connect;
//   NMSMTP1.PostMessage.FromAddress       := 'your_mail@host.com';
//   NMSMTP1.PostMessage.ToAddress.Text    := 'delphiworld@mail.ru';
//   NMSMTP1.PostMessage.ToCarbonCopy.Text := 'your_mail@host.com';
//   NMSMTP1.PostMessage.ToBlindCarbonCopy.Text := 'second_your_mail@host.com';
//   NMSMTP1.PostMessage.Body.Text         := 'This is the message from Delphi World project';
//   NMSMTP1.PostMessage.Attachments.Text  := 'c:\File.txt';
//   NMSMTP1.PostMessage.Subject           := 'Delphi World is Great!';
//   NMSMTP1.SendMail;
//   ShowMessage('Mail sent !');
//   NMSMTP1.Disconnect;
// try
//   IdSMTP1.Host:='aspmx.l.google.com';
//   IdSMTP1.AuthenticationType:=atNone;
//   IdSMTP1.Username:='didos00@yandex.ru';
//   IdSMTP1.Password:='Hortcasey071384';
//   IdSMTP1.Port:=25;

//   IdSMTP1.Connect;

//   msg:=TIdMessage.Create(nil);
//   msg.Body.Add('test mail');
//   msg.Subject:='header message';
//   msg.From.Address:='ke452e@gmail.com';
//   msg.From.Name:='Сергей Селиванов';
//   msg.Recipients.EMailAddresses:='ke452e@gmail.com';
//   msg.IsEncoded:=True;

//   IdSMTP1.Send(msg);
//   msg.Free;
//   IdSMTP1.Disconnect;
// except
// on e:Exception do
// begin
//   msg.Free;
//   IdSMTP1.Disconnect;
// end;
// end;
//end;
end;

procedure TForm7.Button2Click(Sender: TObject);
var i:integer;
begin
  with Printer do
  begin
    BeginDoc; { Начало печати }
    for i:=0 to memo1.Lines.Count do
    begin
      Canvas.TextOut(100,i*100,memo1.Lines[i]);
    end;
//        Canvas.TextOut(100,100,'Это тест принтера !!!'); { Печатаем текст }
    EndDoc; { Конец печати }
  end;
end;

end.

