»áÔ±£º ÃÜÂ룺 ¡¡Ãâ·Ñ×¢²á | Íü¼ÇÃÜÂë | »áÔ±µÇ¼ ÍøÒ³¹¦ÄÜ£º ¼ÓÈëÊÕ²Ø ÉèΪÊ×Ò³ ÍøÕ¾ËÑË÷  
¼¼ÊõÎĵµ > Delphi
DelphiÈÃÄã·¢ËÍFlashµç×ÓÓʼþ
·¢±íÈÕÆÚ£º2003-07-22 00:00:00×÷Õߣº½ ³ö´¦£º  

¡¡¡¡ÎÞÂÛOutlook XP»¹ÊÇ×îеÄFoxmail 4.0£¬¶¼Ö»ÄÜÔÚHTML¸ñʽµÄµç×ÓÓʼþÖÐǶÈëJPG¡¢GIF¸ñʽͼƬ£¬¶øÒôÉ«¾ã¼ÑµÄFlash¶¯»­È´Ö»ÄÜ×÷Ϊµç×ÓÓʼþ¸½¼þ·¢Ë͸øºÃÓÑ£¬Äã¿ÉÔø¸Ðµ½Òź¶£¿

¡¡¡¡¾­¹ýÒ»·¬ÊµÑé̽Ë÷£¬ÎÒʹÓÃDelphiÖÕÓÚʵÏÖÁ˽«Flash¶¯»­£¨.SWF¸ñʽ£©Ç¶Èëµ½µç×ÓÓʼþÕýÎÄÖз¢Ë͵ŦÄÜ£¬Foxmail¡¢Outlook¾ù¿ÉÒÔ°´ÕÕHTML¸ñʽµÄÓʼþ²é¿´£¬¶øÇÒ263¡¢163µÈÃâ·Ñµç×ÓÓʼþ»¹Ö§³ÖWeb½çÃæÖ±½Óä¯ÀÀ¡£¿ÉϧµÄÊÇ£¬Sina¡¢SohuÃâ·Ñµç×ÓÓʼþµÄWeb½çÃæÔò²»Ö§³Ö£¬Ö»Äܽ«Flash¶¯»­×÷Ϊ¸½¼þÌṩ¡£

¡¡¡¡Ò»¡¢³ÌÐòÔ­Àí

¡¡¡¡ÏÂÃæ¶Ô±¾³ÌÐòÏà¹ØµÄÖØÒªÀíÂÛ֪ʶ×öЩ½âÊÍ£¬°ïÖú´ó¼ÒÀí½â±¾³ÌÐòµÄÔ­Àí¡£¸ü¶àµÄÄÚÈÝ£¬ÏÞÓÚÎÄÕÂƪ·ù£¬Çë²Î¼ûÏà¹ØµÄ²Î¿¼Êé¡¢°ïÖúÎļþ¡£

¡¡¡¡1.TNMSMTP¿Ø¼þ

¡¡¡¡µç×ÓÓʼþ·¢Ë͹ý³Ì¶¼±ØÐë×ñÑ­SMTPЭÒé¡£¿Í»§¶ËºÍ·þÎñÆ÷ͨ¹ý¸ÃЭÒé½øÐÐͨÐÅ£¬ÓÉ¿Í»§¶Ë·¢Ëͳöµç×ÓÓʼþ£¬SMTP·þÎñÆ÷ͨ¹ýÍøÂçÉÏÆäËûSMTP·þÎñÆ÷£¬×îÖÕ½«Óʼþ´«µÝµ½ÊÕÐÅÈ˵ÄÓʼþ·þÎñÆ÷¡£±¾³ÌÐò×÷Ϊµç×ÓÓʼþ¿Í»§¶Ë³ÌÐò£¬×î»ù±¾µÄ¹¦ÄÜÊÇҪʵÏÖµç×ÓÓʼþ·¢ËÍ£¬ÎªÁ˼ò»¯±à³Ì£¬Ê¹ÓÃÁËDelphi 5×Ô´øµÄTNMSMTP¿Ø¼þ£¬¸Ã¿Ø¼þ·â×°Á˶ÔSMTP±à³Ì¡£ÓÉÓڸÿؼþ¼Ì³Ð×ÔTPowersock£¬Òò¶ø±ØҪʱ¿ÉÒÔÖ±½Óµ÷ÓõײãµÄSocket¹ý³Ì£¬ÓÖ²»Ê§Áé»îÐÔ¡£

¡¡¡¡ÀýÈ磬ËäÈ»TNMSMTP²»Ö±½ÓÖ§³Ö¡°SMTP·þÎñÆ÷ÈÏÖ¤¹¦ÄÜ¡±£¨Çë²Î¿¼¡¶µçÄÔ°®ºÃÕß¡·2001Äê16ÆÚ¡¶ÖÆ×÷Ö§³Ö¡°·þÎñÆ÷ÈÏÖ¤¡±µÄVBµç×ÓÓʼþ³ÌÐò¡·£¬°üÀ¨ÏÂÎÄ¡°BASE64±àÂ롱£©£¬µ«ÊÇ£¬¿ÉÒÔÀûÓÃTNMSMTPµÄConnectʼþºÍ¼Ì³Ð×ÔTPowersockµÄTransaction·½·¨£¬ÊµÏÖSMTP·þÎñÆ÷ÈÏÖ¤¡£ÆäÔ­ÀíÔÚÓÚ£¬Connectʼþ·¢ÉúÔÚTNMSMTPÓë·þÎñÆ÷Á¬½Ó³É¹¦Ö®Ê±£¬´Ëʱ£¬Ê¹ÓÃTransaction·½·¨·¢³öSMTP·þÎñÆ÷ÈÏÖ¤Ëù¹æ¶¨µÄ¡°AUTH LOGIN¡±ÃüÁ²¢ÊäÈë¾­¹ýBASE64±àÂëºóµÄÓû§ÃûºÍÃÜÂ룬¿ÉÒÔʵÏÖÈÏÖ¤¡£Òò´Ë£¬±¾³ÌÐòʵÏÖÁËSMTP·þÎñÆ÷ÈÏÖ¤¡£

¡¡¡¡ÁíÍ⣬TNMSMTPµÄSendStartʼþÔÚÓʼþ·¢ËÍ¿ªÊ¼Ê±´¥·¢£¬ÔÚ¸ÃʼþÖУ¬¿ÉÒÔͨ¹ýÐÞ¸ÄTNMSMTPµÄFinalHeaderÊôÐÔÖµ£¬ÊµÏÖÐ޸ĵç×ÓÓʼþµÄÓʼþÍ·ÐÅÏ¢¡£ÔÚ±¾³ÌÐòÖÐÐèÒªÐÞ¸ÄÓʼþÍ·µÄContent-TypeÊôÐÔ£¬Ê¹½ÓÊÕǶÈëFlash¶¯»­µç×ÓÓʼþµÄ¿Í»§¶ËÈí¼þ£¨ÈçFoxmail£©ÄÜÕýÈ·´¦ÀíÓʼþÄÚÈÝ¡£

¡¡¡¡2.MIMEЭÒé

¡¡¡¡Ä¿Ç°£¬¼¸ºõËùÓеÄÓʼþ·þÎñÆ÷ºÍ¿Í»§¶ËÈí¼þ¶¼Ö§³Ö¡°¶àÓÃ;InternetÓʼþÀ©Õ¹¡±Ð­ÒéMultipurpose Internet Mail Extensions (MIME)¡£¸ÃЭÒéµÄ×îаæÓÉRFC2045£¨InternetÏûÏ¢Ìå¸ñʽ£©¡¢RFC2046£¨Ã½ÌåÀàÐÍ£©¡¢RFC2047£¨ÎÞASCIIÎı¾ÏûϢͷÀ©Õ¹£©¡¢RFC2048£¨×¢²á¹ý³Ì£©¡¢RFC2049£¨Ò»ÖÂÐÔ±ê×¼ºÍÀý×Ó£©µÈ¹²Í¬¹æ¶¨¡£¸ÃЭÒé×ñÑ­ÁËRFC822Öй涨µÄµç×ÓÓʼþÄÚÈÝÖ»ÄÜ°üÀ¨¼òµ¥µÄASCIIÎı¾×Ö·û£¨Èç×Öĸ¡¢Êý×Ö¡¢±êµã·ûºÅµÈ£©£¬¶¨ÒåÁËÔÚµç×ÓÓʼþÖаüÀ¨¾­¹ý±àÂëµÄ¶þ½øÖÆÎļþµÄ·½·¨£¬±àÂëºóµÄÄÚÈݽ«Ö»°üÀ¨Îı¾×Ö·û¡£Ä¿Ç°£¬ÊµÏÖ¶Ô¶þ½øÖÆÎļþ±àÂëµÄ¹æ·¶Óкܶ࣬BASE64±àÂë¹æ·¶Ò²ÊÇÆäÖÐÖ®Ò»¡£±¾³ÌÐòʹÓÃTMemoryStream¶ÔÏó£¬ÊµÏÖÁËͨÓõÄBASE64±àÂ뺯ÊýEncodeBASE64£¬Äܹ»¶ÔSWFÎļþ½øÐбàÂë¡£

¡¡¡¡Í¨¹ýMIMEЭÒ飬µç×ÓÓʼþÖв»µ«¿ÉÒÔÌí¼Ó¸½¼þ£¬»¹¿ÉÒÔÌí¼ÓHTML¸ñʽÄÚÈÝ£¬°üÀ¨Í¼Æ¬¡¢ÉùÒô¡¢¶¯»­µÈ¡£Outlook¡¢Foxmail 4.0µÈÈí¼þ¶¼¿ÉÒԱ༭HTML¸ñʽµÄÓʼþ£¬µ«ÊDz¢²»Ö§³ÖÖ±½ÓǶÈëFlash¶¯»­¡£ÊÂʵÉÏ£¬ÕýÈ·ÀûÓÃMIMEЭÒ飬¿ÉÒÔÔÚHTML¸ñʽµÄÓʼþÖÐǶÈëFlash¶¯»­£¬²¢ÔÚÓʼþÕýÎÄÖÐÏÔʾ³öÀ´£¬ÆäÔ­ÀíºÍÔÚHTML¸ñʽÓʼþÖÐÏÔʾͼƬ¡¢²¥·ÅÉùÒôÊÇÒ»ÑùµÄ¡£ÔÚHTML¸ñʽÓʼþÖÐǶÈëFlash¶¯»­ÓëÏòÍøÒ³ÖÐÌí¼Ó¶¯»­ËùÐèÒªµÄ´úÂëÊÇÒ»ÑùµÄ£¬Í¬ÑùʹÓÃ< OBJECT >¡¢< EMBED >±ê¼Ç£¬¸ÐÐËȤµÄÅóÓÑ¿ÉÒԲ鿴һ¸ö°üº¬Flash¶¯»­µÄÍøÒ³Ô´´úÂ룬¶Ô±È±¾³ÌÐò¡£

¡¡¡¡ÔÚ±¾³ÌÐòÖУ¬ÉèÖÃÓʼþMIMEÏûϢͷµÄContent-TypeÊôÐÔΪmultipart/related; boundary="---SwfEmail by JDH"£¬±íʾ¸ÃÓʼþ°üÀ¨¶à¸ö²»Í¬Êý¾ÝÀàÐ͵IJ¿·Ö£¬¸÷¸ö²¿·ÖÖ®¼äÓÃ"---SwfEmail by JDH"£¨²»°üÀ¨ÒýºÅ£©Çø·Ö¡£ÔÚÓʼþÄÚÈݵÄÕâЩ²¿·ÖÖУ¬¸ù¾Ýÿ²¿·ÖµÄÄÚÈݲ»Í¬£¬ÔÙΪÆäÌí¼ÓÏàÓ¦µÄMIMEÏûϢͷ£¬¾ßÌå¿É²Î¼û³ÌÐòÔ´´úÂë¡£

¡¡¡¡¶þ¡¢±à³Ìʵս

¡¡¡¡Æô¶¯Delphi 5£¬²Î¿¼Í¼1ÔÚForm1ÉÏ´´½¨¸÷Öֿؼþ¡£Í¼ÖкÚÉ«·½¿òÄÚ±êÃ÷Á˿ؼþÃû³Æ£¬ÆäÖÐtxtǰ׺±íʾTEdit¿Ø¼þ£¬memǰ׺±íʾTMemo¿Ø¼þ£¬chkǰ׺±íʾTCheckbox¿Ø¼þ£¬btnǰ׺±íʾTButton¿Ø¼þ£¬NMSMTP1ÊÇTNMSMTP¿Ø¼þ£¬OpenDialog1ÊÇTOpenDialog¿Ø¼þ¡£Í¼2ÁгöÁËÒ»²¿·Ö¿Ø¼þµÄijЩ¹Ø¼üÊôÐÔ¡£

ÏÖÔÚÌí¼Ó´úÂëÈçÏ£º

{******Unit1.pasÔ´´úÂëÄÚÈÝÈçÏÂ******}

unit Unit1;

interface

uses

Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,

Dialogs, StdCtrls, ExtCtrls, Psock, NMsmtp;

type

TForm1 = class(TForm)

Label1: TLabel;

txtTo: TEdit;

Label2: TLabel;

txtFrom: TEdit;

Label3: TLabel;

txtSubject: TEdit;

Label4: TLabel;

memContents: TMemo;

Label5: TLabel;

txtUserName: TEdit;

Label6: TLabel;

txtPassword: TEdit;

chkSmtpVerify: TCheckBox;

btnSend: TButton;

btnOpen: TButton;

txtSwfFile: TEdit;

Label7: TLabel;

OpenDialog1: TOpenDialog;

Label8: TLabel;

txtSmtpServer: TEdit;

NMSMTP1: TNMSMTP;

Label9: TLabel;

txtPort: TEdit;

procedure btnOpenClick(Sender: TObject);

procedure btnSendClick(Sender: TObject);

procedure NMSMTP1SendStart(Sender: TObject);

procedure NMSMTP1Connect(Sender: TObject);

procedure chkSmtpVerifyClick(Sender: TObject);

private

{ Private declarations }

public

{ Public declarations }

end;

var

Form1: TForm1;

function EncodeString(Decoded:string):String;

function EncodeBASE64(Encoded: TMemoryStream {TMailText}; Decoded: TMemoryStream):

Integer; //±àÂ뺯Êý

implementation

{$R *.dfm}

{¶Ô²ÎÊýTMemoryStremaÖеÄ×Ö½ÚÁ÷½øÐÐBase64±àÂ룬±àÂëºóµÄ½á¹û

±£´æÔÚEncodedÖУ¬º¯Êý·µ»Ø±àÂ볤¶È}

function EncodeBASE64(Encoded: TMemoryStream ; Decoded: TMemoryStream): Integer;

const

_Code64: String[64] =

('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/');

var

I: LongInt;

B: array[0..2279] of Byte;

J, K, L, M, Quads: Integer;

Stream: string[76];

EncLine: String;

begin

Encoded.Clear;

Stream := '';

Quads := 0;

{ΪÌá¸ßЧÂÊ£¬Ã¿2280×Ö½ÚÁ÷Ϊһ×é½øÐбàÂë}

J := Decoded.Size div 2280;

Decoded.Position := 0;

{¶ÔÇ°J*2280¸ö×Ö½ÚÁ÷½øÐбàÂë}

for I := 1 to J do

begin

Decoded.Read(B, 2280);

for M := 0 to 39 do

begin

for K := 0 to 18 do

begin

L:= 57*M + 3*K;

Stream[Quads+1] := _Code64[(B[L] div 4)+1];

Stream[Quads+2] := _Code64[(B[L] mod 4)*16 + (B[L+1] div 16)+1];

Stream[Quads+3] := _Code64[(B[L+1] mod 16)*4 + (B[L+2] div 64)+1];

Stream[Quads+4] := _Code64[B[L+2] mod 64+1];

Inc(Quads, 4);

if Quads = 76 then

begin

Stream[0] := #76;

EncLine := Stream+#13#10;

Encoded.Write(EncLine[1], Length(EncLine));

Quads := 0;

end;

end;

end;

end;

{¶ÔÒÔ2280ΪģµÄÓàÊý×Ö½ÚÁ÷½øÐбàÂë}

J := (Decoded.Size mod 2280) div 3;

for I := 1 to J do

begin

Decoded.Read(B, 3);

Stream[Quads+1] := _Code64[(B[0] div 4)+1];

Stream[Quads+2] := _Code64[(B[0] mod 4)*16 + (B[1] div 16)+1];

Stream[Quads+3] := _Code64[(B[1] mod 16)*4 + (B[2] div 64)+1];

Stream[Quads+4] := _Code64[B[2] mod 64+1];

Inc(Quads, 4);

{ÿÐÐ76¸ö×Ö·û}

if Quads = 76 then

begin

Stream[0] := #76;

EncLine := Stream+#13#10;

Encoded.Write(EncLine[1], Length(EncLine));

Quads := 0;

end;

end;

{¡°=¡±²¹Î»}

if (Decoded.Size mod 3) = 2 then

begin

Decoded.Read(B, 2);

Stream[Quads+1] := _Code64[(B[0] div 4)+1];

Stream[Quads+2] := _Code64[(B[0] mod 4)*16 + (B[1] div 16)+1];

Stream[Quads+3] := _Code64[(B[1] mod 16)*4 + 1];

Stream[Quads+4] := '=';

Inc(Quads, 4);

end;

if (Decoded.Size mod 3) = 1 then

begin

Decoded.Read(B, 1);

Stream[Quads+1] := _Code64[(B[0] div 4)+1];

Stream[Quads+2] := _Code64[(B[0] mod 4)*16 + 1];

Stream[Quads+3] := '=';

Stream[Quads+4] := '=';

Inc(Quads, 4);

end;

Stream[0] := Chr(Quads);

if Quads > 0 then

begin

EncLine := Stream+#13#10;

Encoded.Write(EncLine[1], Length(EncLine));

end;

Result := Encoded.Size;

end;

{¶Ô²ÎÊýDecoded×Ö·û´®½øÐÐBase64±àÂ룬·µ»Ø±àÂëºóµÄ×Ö·û´®}

function EncodeString(Decoded:string):String;

var

mmTemp,mmDecoded:TMemoryStream;

strTemp:TStrings;

begin

mmTemp := TMemoryStream.Create;

mmDecoded:=TMemoryStream.Create;

strTemp:=TStringList.Create;

strTemp.Add(Decoded);

strTemp.SaveToStream(mmTemp);

mmTemp.Position := 0;

{ÌÞ³ýmmTemp´ÓstrTempÖдøÀ´µÄ×Ö·û#13#10}

mmDecoded.CopyFrom(mmTemp,mmTemp.Size-2);

{¶ÔmmDecoded½øÐÐBase64±àÂ룬ÓÉmmTemp·µ»Ø±àÂëºóµÄ½á¹û}

EncodeBASE64(mmTemp,mmDecoded);

{»ñµÃBase64±àÂëºóµÄ×Ö·û´®}

mmTemp.Position:=0;

strTemp.LoadFromStream(mmTemp);

{·µ»Ø½á¹û±ØÐë´ÓstrTemp[0]ÖлñµÃ£¬Èç¹ûʹÓÃstrTemp.Text»á

´øÀ´²»±ØÒªµÄ×Ö·û#13#10}

Result:=strTemp[0];

end;

procedure TForm1.btnOpenClick(Sender: TObject);

begin

{´ò¿ª¶Ô»°¿ò£¬Ñ¡ÔñSWFÎļþ}

if OpenDialog1.Execute then

begin

end;

end;

procedure TForm1.btnSendClick(Sender: TObject);

var

mmSwfFile,mmEncoded:TMemoryStream;

iResult:Integer;

strsTemp:TStrings;

strContents:TStringList;

i:Integer;

begin

{ÑéÖ¤Óû§ÊäÈëÐÅÏ¢}

if txtTo.Text='' then

begin

ShowMessage('ÇëÊäÈëÊÕÐÅÈË£¡');

Exit;

end;

if txtFrom.Text='' then

begin

ShowMessage('ÇëÊäÈë·¢ÐÅÈË£¡');

Exit;

end;

if txtSmtpServer.Text='' then

begin

ShowMessage('ÇëÊäÈëSMTP·þÎñÆ÷£¡');

Exit;

end;

if txtPort.Text='' then

begin

ShowMessage('ÇëÊäÈë¶Ë¿ÚºÅ£¡');

Exit;

end;

if txtSwfFile.Text='' then

begin

ShowMessage('ÇëÑ¡ÔñSWFÎļþ!');

Exit;

end;

{¼ìÑé·þÎñÆ÷ÈÏÖ¤µÄÓû§ÃûºÍÃÜÂë}

if chkSmtpVerify.Checked = True then

if (txtUserName.Text='') or (txtPassword.Text='') then

begin

ShowMessage('ÄúÒÑÑ¡ÔñSMTP·þÎñÆ÷ÐèÒªÈÏÖ¤'+#13#10+'ÇëÊäÈëÓû§ÃûºÍÃÜÂ룡');

Exit;

end;

{ÉèÖÃSMTP·þÎñÆ÷µØÖ·¡¢¶Ë¿Ú}

NMSMTP1.Host:=txtSmtpServer.Text;

NMSMTP1.Port:=StrToInt(txtPort.Text);

{¶Ï¿ªÔ­À´µÄÁ¬½Ó£¬±£Ö¤TForm1.NMSMTP1ConnectÖзþÎñÆ÷ÈÏÖ¤µÄÖ´ÐÐ}

if NMSMTP1.Connected then

begin

NMSMTP1.Disconnect;

end;

{Á¬½Ó·þÎñÆ÷}

NMSMTP1.Connect;

{´´½¨Á÷}

mmSwfFile:=TMemoryStream.Create;

mmEncoded:=TMemoryStream.Create;

{¼ÓÔØÎļþÖÁÁ÷mmSwfFile}

mmSwfFile.LoadFromFile(txtSwfFile.Text);

{¶ÔmmSwfFile½øÐÐBase64±àÂ룬mmEncodedΪ±àÂëºóÄÚÈÝ}

iResult:=EncodeBASE64(mmEncoded,mmSwfFile);

strsTemp:=TStringList.Create;

mmEncoded.Position:=0;

strsTemp.LoadFromStream(mmEncoded);

{----Éú³ÉÓʼþÄÚÈÝ----}

strContents:=TStringList.Create;

strContents.Add('--------------SwfEmail by JDH');

strContents.Add('Content-Type: text/html; charset=gb2312');

strContents.Add('Content-Transfer-Encoding: 8bit');

{×¢Ò⣺¿ÕÐÐÊÇÓʼþ¸ñʽËù±ØÐèµÄ£¡}

strContents.Add('');

strContents.Add('< HTML>< HEAD>< TITLE>SWFEMAIL< /TITLE>< /HEAD>');

strContents.Add('< BODY>');

{Ìí¼ÓÓʼþÕýÎÄÄÚÈÝ}

for i:=0 to memContents.Lines.Count-1 do

begin

strContents.Add(memContents.Lines[i] + '< br>');

end;

{Ìí¼ÓSWFÎļþÏà¹ØÄÚÈÝ}

strContents.Add('< object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"

codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/

swflash.cab#version=5,0,0,0">');

strContents.Add('< param name=movie value="cid:jdh_swfemail@001">');

strContents.Add('< param name=quality value=high>');

strContents.Add('< embed src="cid:jdh_swfemail@001" quality=high

pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"

type="application/x-shockwave-flash" >');

strContents.Add('< /embed>< /object>< /BODY>< /HTML>');

strContents.Add('');

strContents.Add('--------------SwfEmail by JDH');

strContents.Add('Content-Type: image/swf');

strContents.Add('Content-ID: < jdh_swfemail@001>');

strContents.Add('Content-Transfer-Encoding: base64');

strContents.Add('Content-Disposition: inline; filename="'+ExtractFileName(txtSwfFile.Text)+'"'

);

strContents.Add('');

strContents.Add(strsTemp.Text);

strContents.Add('');

{----Éú³ÉÓʼþÄÚÈݽáÊø----}

{ÉèÖÃÓʼþ·¢ËÍÐÅÏ¢}

NMSMTP1.PostMessage.FromAddress := txtFrom.Text;

NMSMTP1.PostMessage.FromName := txtFrom.Text;

NMSMTP1.PostMessage.ToAddress.Text := txtTo.Text;

NMSMTP1.PostMessage.Body.Text := strContents.Text;

NMSMTP1.PostMessage.Subject := txtSubject.Text;

{·¢Ë͵ç×ÓÓʼþ}

NMSMTP1.SendMail;

ShowMessage('Óʼþ·¢Ëͳɹ¦£¡');

end;

procedure TForm1.NMSMTP1Connect(Sender: TObject);

var

strUserName,strPassword:string;

begin

{Èç¹ûSMTP·þÎñÆ÷ÐèÒªÈÏÖ¤£¬Ôò½øÐÐÈÏÖ¤}

if chkSmtpVerify.Checked = True then

begin

{¶ÔÓû§ÃûºÍÃÜÂë½øÐÐBase64±àÂë}

strUserName:=EncodeString(txtUserName.Text);

strPassword:=EncodeString(txtPassword.Text);

{½øÐÐÈÏÖ¤£¬ÊäÈë±àÂëºóµÄÓû§Ãû¡¢ÃÜÂë}

nmsmtp1.Transaction('auth login');

nmsmtp1.Transaction(strUserName);

nmsmtp1.Transaction(strPassword);

end;

end;

procedure TForm1.NMSMTP1SendStart(Sender: TObject);

begin

{ÔÚÓʼþ·¢ËÍ¿ªÊ¼Ê±ÐÞ¸ÄÓʼþµÄÏûϢͷ£¬±êÃ÷ÓʼþΪ¶à²¿·Ö×é³É}

NMSMTP1.FinalHeader.Values['Content-Type'] := 'multipart/related;

boundary="------------SwfEmail

by JDH"';

end;

procedure TForm1.chkSmtpVerifyClick(Sender: TObject);

begin

{¸ù¾ÝÊÇ·ñÐèÒªSMTP·þÎñÆ÷ÈÏÖ¤£¬¸Ä±äÓû§Ãû¡¢ÃÜÂë״̬}

if chkSmtpVerify.Checked = True then

begin

txtUserName.Enabled := True;

txtUserName.Color:= clWindow;

txtPassword.Enabled := True;

txtPassword.Color:= clWindow;

end

else

begin

txtUserName.Enabled := False;

txtUserName.Color:= clSilver;

txtPassword.Enabled := False;

txtPassword.Color:= clSilver;

end;

end;

end.

¡¡¡¡Èý¡¢³ÌÐòÔËÐÐ

¡¡¡¡Ê×ÏÈÔÚDelphi 5ÖбàÒëÔËÐУ¬½Ó×ÅÔÚ¶Ô»°¿òÖÐÊäÈëÊÕÐÅÈË¡¢·¢ÐÅÈË¡¢Ö÷Ìâ¡¢ÕýÎÄÄÚÈÝÒÔ¼°SMTP·þÎñÆ÷£¬±ÈÈçÌîд¡°smtp.263.net¡±£¬¶Ë¿ÚºÅʹÓÃĬÈϵÄ25£¬Ñ¡ÖС°SMTP·þÎñÆ÷ÐèÒªÈÏÖ¤¡±£¬²¢¸ù¾Ý·¢ÐÅÈËÊäÈëÓû§Ãû¡¢ÃÜÂë¡£µ¥»÷¡°´ò¿ªÎļþ¡±°´Å¥£¬Ñ¡ÔñÒª·¢Ë͵ÄFlash¶¯»­Îļþ£¬È·ÈÏÎÞÎóºó£¬µ¥»÷¡°·¢ËÍ¡±°´Å¥¼´¿É¡£·¢Ëͳɹ¦ºó£¬»á³öÏÖ·¢Ðųɹ¦¡£

¡¾·µ»Ø¶¥²¿¡¿ ¡¾´òÓ¡±¾Ò³¡¿ ¡¾¹Ø±Õ´°¿Ú¡¿

¹ØÓÚÎÒÃÇ / ¸øÎÒÁôÑÔ / °æȨ¾Ù±¨ / Òâ¼û½¨Òé / ÍøÕ¾±à³ÌQQȺ   
Copyright ©2003- 2024 Lihuasoft.net webmaster(at)lihuasoft.net ¼ÓÔØʱ¼ä 0.00392