΢͵Ӧ
MICROCOMPUTER APPLICATIONS
2000Vol.16No.1P.28-30



IntranetϢѯϵͳĵʼ
Զϵͳƺʵ
ҡǡ֮ 
ժҪҵIntranetԭеϢѯϵͳһʼԶϵͳϵͳԶʱظҵԱIntranetϵĵ䷢ͲѯϵͳݿеϢժҪݣṩһʹԱԺܷᵽѯϵͳڷڵʼSMTPЭĻϣ˸ϵͳDelphiʵֹ̡
ؼʣIntranetʼSMTP
AbstractThis paper introduces an email- autosending subs ystem, which sends the latest abstract information in the query database to rele vant employees by email at the specified time as well as providing hyperlinks to the query database. It is incorporated into the Intranet-based Information Quer y System. This paper also presents its implementation using Delphi based on the analysis of SMTP protocol.
KeywordsIntranetE-mailSMTP
һǰ
ҵIntranetѽһϢѯϵͳΪԱӼʱ˽ѯϵͳݣʹԱϢϵͳʹøĿԡԣʡʱ䣬ΪϵͳһʼԶϵͳϵͳԶڵؽѯϵͳеϢժҪ͵ϢйصԱĵСԱͿͨʼʱ˽ݣͨȤݵĳᵽϢѯϵͳеҳ档
ڷ˵ʼInternet/IntranetϴԭЭĻϣԭвѯϵͳݿ˱ҪģݿInternet/IntranetӦó򿪷ǿܵDelphi4.0C/S汾Ϊƽ̨ʵ˵ʼԶϵͳ
ʼԭҵIntranet
1.ʼԭ
ʼInternetĴͳ֮һŻTCP/IPIntranet𣬵ʼҲΪIntranetϵҪ֮һTCP/IPģ͵Ӧò㶨Э飬аڵʼЭ顪SMTP(ʼЭ)ЭüѻŶӵķʽͻ˵ʼ͵֧SMTPЭʼ(ΪSMTP)ԼSMTPתһ͵Ĵӷͷշĵʼͼ1ʾ

ͼ1 ʼĵʹ
SMTPЭһֻTCP/IPЭ飬ڿͻ˷ʼʱSMTPһTCPӣȻ󣬿ͻͿSMTPHELOMAILFROMRCPT TODATAQUITȵÿSMTP󣬷ͻ˷һӦ״̬Ƿ񱻳ɹִСDelphi4.0еSMTPؼʵӺ͵ʼķ͡
2.ҵIntranetɼԭвѯϵͳݿ
ϵͳMicrosoft Windows NT Server 4.0İ(IIS3.0)ݿϵͳMicrosoft SQL Server 6.5ʼMicrosoft Exchange Server5.5ȹɣSQL ServerһϢѯϵͳݿ⣬ԱϢ뱾ϵͳйصݿĽܵĵʼԶϵͳҪǴϢݿвϢժҪ䷢͵ϢйصԱĵС
Ϊ˸õеϵͳԴԭݱһ޸ġԭԱеʼֶַΣϢϢժҪʱ䡢ϢݡϢWebϵ·ֶΡΪʹĳϢֻϢйصԱзֱһֶΣԱϢԷࡣϢһ߼ֶǸϢǷѳɹ͸ԱϢռݿʱֶȱʡΪδ͡ڸñоͿԲҳӵϢֶεֵ͸ӦԱͳɹֶεֵͱΪѷ͡Ϊδ͡´ηʱٴϢ֮С
Delph4.0ʵֵʼԶϵͳ
ϵͳƳɶʱԶУҹ賿ȽϿʱϵͳԶѯϵͳݿеϢ
һһӦԱĵСֻһ һЩϵͳѡãʼơTCP˿ںšݿݿƣԼϵͳʱȸѡ
Delphi4.0½һApplicationڱϷһINMSMTPؼTQueryһTTimerϵͳõTLabelTEditTMaskEditȿؼԼֱ˳úֹ͵TButtonఴť
interfaceĸڱȱʡֵĹб
var TimeStr:string=`00:00';
Server:string=`192.168.0.1';
Port:integer=25;
DBName:string=`InfoSystem';
Զ̣
private
procedure SaveSettings;//ڽйرϵͳñϵͳע
Procedure ActoSend//ڷϢ
ΪԼƪֻʵֵʼ͵AutoSend̵Դ롣
procedure TForml.AutoSend;
var
info.groupin:array of String://̬飬ϢݿжժҪϢϢĹ
dim,i:integer;
begin
try
if radiogroupl.itemindex=0 then
nmsmtpl.Encode Type:=uuMine
else
nmsmtp1.EnccdeType:=uuCode;
nmsmtp1.hort:=server;
nmsmtp1.port:=port;
nmsmtp1.Connect;
except
on Exception do exit;
end;
dim:=0;
query1.DatabaseName:=DBName;
query1.RequestLive:=Ture;//Ϊquery1ѯϢݿ⣬ͺ޸Ƿѷ͵ı־ֶ
query2.databasename:=DBName;
if query1.state<>dsInactive then queryl.close;
queryl.SQL.clear;
//Ϣݿвδ͵Ϣڡ·ժҪϢ
queryl.SQL.add(`select appenddate,virtualpath.title,groupIn from info where sent=0 order by GroupIn');
queryl.open;
//潫ͬϢϲԱ
while not queryl.eof do begin
//̬ĳȼ1ʹϢĹĿͬ
dim:=dim+1;
setlength(info.dim);
setlength(groupin,dim);
groupindim-1:=query1.Fields3.asstring;
while not query1.eof and(groupindim-1=query1.fields3.asstring)do begin
infodim-1:=infodim-1+query1.fields0.asstring+#32#32+`http://192.168.0.1'+query1.Fields1.asstring+#10+query1.Fields2.asstring+#10#10;
query1.next;
end
end
//ÿϲϢ͸ӦԱ
for i:=0 to high(groupin)do
begin
if query2.state<>dsInactive then query2.close;
query2.sql.clea.
//Աݿв뵱ǰϢͬԱEmailַ
query2.sql.add(`select email from employee where groupin='+#34+groupini+#34);
query2.open;
//潫Ϣ͸ӦԱԱemailַquery2εõ
while not quer2.eof do begin
nmsmtp1.ClearParameters;
with NMSMTP1.PostMessage do begin
Body.Clear;
ToAddress.Add(query2.Fields0.asstring);
FromAddress:=`postmaster@192.168.0.1';
FromName:='PostMaster';
Body.Add(infoi)
Subject:='Ϣ';
end
query2.next;
try
NMSMTP1.SendMail
except
continue,
end
end
try
if query1.state<>DsInactive then query1.Close;
queryl.SQL.clear;
queryl.sql.Add('update info set sent=1 where groupin='+#34+groupini+#34);
queryl.ExecSQL;//ѷϢsentֶΪ1ʾѷ
except
on Exception do exit;
end;
end;
query1.Close;
query2.Close;
NMSMTP1.Disconnect;//϶Ͽʼ
end
ġ
ĸҵIntranetϢѯϵͳҪƺʵһʼԶϵͳܽѯϵͳݿϢժҪԶʱط͸ҵԱʹܹӷ㡢ʱ׼ȷ˽ѯϵͳеϢԷͨѸٷʲѯϵͳеϸϢϵͳĿǰãյһԤЧ
ߵλ(ϺͨѧԶϵ Ϻ 200030)
֮(ϺͨѧԶϵ  ʿʦ Ϻ 200030)
οף
1ʯңƷʼоʵ֣Ӧá1998.12
2Tom swan, Foundations of Delphi Development For Windows95.ӹҵ硡1997
3Delip C.Naik,Internet׼Э飬廪ѧ硡1999
4PFC821Simple Mail Transfer Protocol
ոڣ1999-07-01
