Delphi4.0 寮鍙慦EBMAIL绋嬪簭
鍙戝竷: 2008-6-26 16:36 | 浣滆: admin | 鏌ョ湅: 5娆
---- 閫氬父锛屽疄鐜癢EBMAIL閲囩敤mailto.exe鐨凜GI銆佸湪HTML鏂囦欢涓啓鍏モ<
form action="mailto:鐢靛瓙閭鍦板潃" method=post >鈥濊鍙ユ垨鑰呰皟鐢╓INDOWS
API鍑芥暟銆傞噰鐢╓INDOWS API 鍜屽湪HTML鏂囦欢涓啓鍏モ< form action="mailto:鐢靛瓙閭鍦板潃"
method=post >鈥濊鍙ラ兘瑕佹眰鐢ㄦ埛鐨勬祻瑙堝櫒瑁呭叆EXCHANGE銆丱UTLOOKEXPRESS銆佹垨OUTLOOK绛夎蒋浠讹紝鑰屼笖杩樻湁涓浜涙祻瑙堝櫒涓嶆敮鎸丮AILTO璇彞銆傝岄噰鐢–GI鐨勫舰寮忓疄鐜癢EBMAIL瀵圭敤鎴风殑娴忚鍣ㄦ病鏈夎姹傦紝浣嗘晥鐜囦笉楂樸侰GI鎶鏈鍦ㄩ愭笎琚獻SAPI/NSAPI鎶鏈墍鍙栦唬銆傛湰鏂囧氨鏉ヨ璁轰竴涓嬮噰鐢↖SAPI鎶鏈疄鐜癢EBMAIL銆
---- 浣跨敤Delphi 4寮鍙慦eb
Server绋嬪簭鏄潪甯哥畝鍗曠殑锛孌elphi 4涓彁渚涗簡澶ч噺鐨勫厓浠跺拰瀵硅薄锛屾敮鎸乄eb
Server绋嬪簭鐨勫紑鍙戙 涓嬮潰閫氳繃涓涓緥瀛愭潵浠嬬粛濡備綍鍒╃敤DELPHI寮鍙戜竴涓搷搴旂敤鎴疯緭鍏ョ殑ISAPI鐨刉EBMAIL绋嬪簭銆傚彧鏈夊湪鍙戦佹湇鍔″櫒涓婃敞鍐岀殑鐢ㄦ埛鎵嶈兘閫氳繃鍦ㄦ祻瑙堝櫒鍙戦侀偖浠躲備负浜嗙畝鍗曪紝绋嬪簭娌℃湁瀵逛紶閫佺殑鏁版嵁鎻愪緵淇濆瘑銆
---- 棣栧厛锛屽湪WEB鏈嶅姟鍣ㄧ瀹夎鏁版嵁搴撳紩鎿巇be,骞惰缃ソ鏁版嵁搴撳埆鍚嶏細yh,鎸囧悜涓涓寘鍚敤鎴峰悕鍜岀敤鎴峰瘑鐮佺殑鏁版嵁搴撴枃浠秛ser.db銆傛帴鐫寤虹珛涓や釜HTML鏂囦欢锛屽悕瀛楀垎鍒负锛歞l.html,qd.html锛屾斁鍦╓EB鏈嶅姟鍣ㄧ殑缂虹渷鐩綍涓嬶紙濡傦細C锛歕INETPUB\WWWROOT锛夈
dl.html鐨勫唴瀹瑰涓嬶細
< html >
< head >< title > 鍙戦侀偖浠剁郴缁< /title >< /head >
< body >
< h1 >鍙戦侀偖浠剁郴缁< /h1 >
< p > 璇疯緭鍏ユ偍鐨勭敤鎴峰悕鍙婂瘑鐮併< /p >
< form method=鈥漰ost鈥 action="/scripts/xsmd" >
< p >鐢ㄦ埛鍚嶏細< input type="text" length=10
name="username" >
瀵嗙爜锛< input type="password"
length=10 name="password" >< /p >
< p >< input type="submit" value="纭畾" >
< input type="reset" value="娓呴櫎" >< /p >
< /form >
< /body >
< /html >
qd.html鏂囦欢鍐呭濡備笅锛
< html >< head >< title >濉〃< /title >< /head >
< body >
< form method=鈥漰ost鈥 action="feedback" >
< p >璇峰~鍏ユ帴鏀堕偖浠跺湴鍧:toaddress:
< input type=鈥漷ext鈥 length=20
name=鈥漷oaddress鈥 >< /p >
< p >璇峰~鍏ヤ富棰樸< input type="text"
length=20 name="subject" >< /p >
< p >鍐呭锛< /p >
< p >< input type=鈥渢extarea鈥漧ength=40
width=40 name=鈥漛ody鈥 >< /p >
< p >< input type="submit" value="纭畾" >
< input type="reset" value="娓呴櫎" >< /p >
< /form >
< /body >
< /html >
銆
---- 鍦―ELPHI涓柊寤轰竴涓熀浜嶪SAPI鐨刉EB
SERVER APPLICATION锛屾墜鍔ㄥ鍔爊msmtp1,query1,pageproducer1銆
---- 鍏朵腑锛歱ageproducer1鐨刾roperty:
htmlfile锛歝:\inetpub\www.root\qd.html銆俷msmtp1鐨 property:host(鍙戦侀偖浠舵湇鍔″櫒鐨勫湴鍧銆)鍦ㄨ繖閲屼负smtp.netease.com.銆俻ort:25銆
鍏ㄥ眬鍙橀噺涓猴細 sername:string;flag:boolean;
澧炲姞涓涓矾寰勪负/feedback鐨勫姩浣滈」锛屽叾浠g爜濡備笅锛
procedure TWebModule1.WebModule1WebActionItem1
Action(Sender: TObject;
Request: TWebRequest; Response:
TWebResponse; var Handled: Boolean);
Var Count:integer;
S:string;
Begin
Query1.close;
Query1.sql.clear;
S:=鈥檚elect count(username) from
user.db where username=鈥濃;
S:=s+request.contentfields.values[鈥榰sername鈥橾+鈥欌濃;
S:=s+鈥 and password=鈥濃;
S:=s+request.contentfields.values[鈥榩sword鈥橾+鈥欌濃;
Query1.sql.add(S);
Query1.open;
If query1.count=0
then response.content:=鈥< html >< head >< title >
< /title >< body >鐢ㄦ埛鍚嶃佸瘑鐮佷笉姝g‘锛岃閲嶆柊杈撳叆
< /body >< /html >鈥
Else
Username:=request.contentfields.values[鈥榰sername鈥橾;
Response.content:=pageproducer1.content;
End;
鍐嶅鍔犱竴涓矾寰勪负/sendmail 鐨勫姩浣滈」锛
瀹冪殑绋嬪簭浠g爜濡備笅锛
procedure TWebModule1.WebModule1Web
ActionItem2Action(Sender: TObject;
Request: TWebRequest; Response:
TWebResponse; var Handled: Boolean);
Var body:string;
Begin
Flag:=true;
body:=request.contentfields.values[鈥榖ody鈥橾;
Pageproducer1.htmldoc.clear;
Pageproducer1.htmldoc.add(鈥< html >< body >鈥);
Nmsmtp1.postmessage.clear;
Nmsmtp1.postmessage.fromaddress:=username+
鈥橜netease.com鈥;
Nmsmtp1.postmessage.from:=username;
Nmsmtp1.postmessage.body.add(body);
Nmsmtp1.postmessage.toaddress.add
(request.contentfields.values[鈥榯oaddress鈥橾);
Nmsmtp1.postmessage.subject:=
request.contentfields.values[鈥榮ubject鈥橾锛
Nmsmtp1.connect;
If flag=true then begin Nmsmtp1.sendmail;
nmsmtp1.disconntent;end
pageproducer1.htmldoc.add
(鈥< /body >< /html >鈥);
response.content:=pageproducer1.content;
end;
澧炲姞nmsmtp1鐨勪簨浠跺涓嬶細
procedure TWebModule1.NMSMTP1Connect(Sender: TObject);
begin
pageproducer1.htmldoc.add
('< p >宸茬粡鍜屽彂閫侀偖浠舵湇鍔″櫒杩炴帴< /p >');
end;
procedure TWebModule1.NMSMTP1Connection
Failed(Sender: TObject);
begin
flag:=false;
pageproducer1.htmldoc.add
('< p >杩炴帴澶辫触< /P >');
end;
procedure TWebModule1.NMSMTP1ConnectionRequired
(var Handled: Boolean);
begin
pageproducer1.htmldoc.add('< p >瑕佹眰杩涜杩炴帴< /p >');
end;
procedure TWebModule1.NMSMTP1Failure(Sender: TObject);
begin
pageproducer1.htmldoc.add('< p >鍙戦侀偖浠跺け璐< /p >');
flag:=false;
end;
procedure TWebModule1.NMSMTP1Header
Incomplete(var handled: Boolean;
hiType: Integer);
begin
pageproducer1.htmldoc.add('< p >head涓嶅畬鏁< /p >');
flag:=false;
end;
procedure TWebModule1.NMSMTP1InvalidHost
(var Handled: Boolean);
begin
pageproducer1.htmldoc.add('< p >
鍙戦侀偖浠舵湇鍔″櫒鍦板潃鏃犳晥< /p >');
flag:=false;
end;
procedure TWebModule1.NMSMTP1RecipientNot
Found(Recipient: String);
begin
pageproducer1.htmldoc.add
('< p >鎺ュ彈閭欢鍦板潃涓嶆纭< /p >');
flag:=false;
end;
procedure TWebModule1.NMSMTP1Success(
Sender: TObject);
begin
pageproducer1.htmldoc.add('< p >
鎴愬姛鍙戦侀偖浠< /p >');
end;




发表于 2009-1-5 19:48
| 











