I am trying to write some code to send an alert email. I have tried to
understand the demo mailcheck, but it is not helping me. Can tou have a look at
the following and advise where I can improve it to get it working?
==============================================================
code:
==============================================================
unit emailalert;
interface
uses
SysUtils,Classes,blcksock,synautil,synacode,SMTPsend, DB, passqlite, passql;
type
EmailSend = class(TThread)
private
smtp: TSMTPSend;
FExtn,Fdest: String;
public
Constructor Create(extn,dest:String);
Destructor Destroy; override;
procedure Execute; override;
public
{ Public declarations }
LiteDB2 : Tlitedb;
end;
implementation
Constructor EmailSend.Create(extn,dest:String);
begin
smtp:=TSMTPSend.Create;
FExtn:= extn;
FDest:= dest;
FreeOnTerminate:=true;
inherited create(false);
end;
Destructor EmailSend.Destroy;
begin
SMTP.Free;
end;
procedure EmailSend.Execute;
Var
SQLQuery1 : PChar;
smtpName,smtpPass,smtpHost,smtpTo,smtpTo2,smtpFrom:String;
smtpMsg:string;
begin
smtpFrom := '[EMAIL PROTECTED]';
smtpMsg := 'A call from '+Fextn+' to '+Fdest+' has been made, which is in a
list of barred numbers';
smtpMsg := smtpMsg+#13#10#13#10'Call Collex';
SQLQuery1:=PChar('SELECT * FROM backup_set');
LiteDB2.Query(SQLQuery1);
LiteDB2.Close;
smtpname := liteDB2.Results[0][6];
smtpPass := liteDB2.Results[0][7];
smtpHost := liteDB2.Results[0][4];
smtpTo := liteDB2.Results[0][1];
if liteDB2.Results[0][6] <> '' then Begin
smtp.UserName := smtpname;
smtp.Password := smtpPass;
smtp.TargetHost := smtpHost;
end;
smtp.Login;
smtp.MailFrom(smtpFrom, Length(smtpFrom));
smtp.MailTo(smtpTo);
smtp.MailData(Tstrings(smtpMsg));
smtp.Logout;
FreeAndNil(smtp);
end;
end.
===========================================
end
==========================================
Thanks
Lloydie T-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
synalist-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/synalist-public