用winsock发送html类型的邮件该怎么办???(100分)

  • 主题发起人 主题发起人 qinglan.ai
  • 开始时间 开始时间
Q

qinglan.ai

Unregistered / Unconfirmed
GUEST, unregistred user!
该代码只能发送text类型的邮件 该如何修改让他发送html类型的邮件呢?!
unit SendMailUnit;

interface

uses windows, winsock;

function DNASendEMail(PSmtp,PUser,PPass,PGetMail,PTOMail,Subject,MailText:string):boolean;

implementation

var
SendBody:string;
const

CRLF=#13#10;
BaseTable:string='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';

function StrLen(const Str: PChar): Cardinal; assembler;
asm
MOV EDX,EDI
MOV EDI,EAX
MOV ECX,0FFFFFFFFH
XOR AL,AL
REPNE SCASB
MOV EAX,0FFFFFFFEH
SUB EAX,ECX
MOV EDI,EDX
end;

function StrCopy(Dest: PChar; const Source: PChar): PChar; assembler;
asm
PUSH EDI
PUSH ESI
MOV ESI,EAX
MOV EDI,EDX
MOV ECX,0FFFFFFFFH
XOR AL,AL
REPNE SCASB
NOT ECX
MOV EDI,ESI
MOV ESI,EDX
MOV EDX,ECX
MOV EAX,EDI
SHR ECX,2
REP MOVSD
MOV ECX,EDX
AND ECX,3
REP MOVSB
POP ESI
POP EDI
end;

function StrPas(const Str: PChar): string;
begin
Result := Str;
end;

function FindInTable(CSource:char):integer;
begin
result:=Pos(string(CSource),BaseTable)-1;
end;

function EncodeBase64(Source:string):string;
var
Times,LenSrc,i:integer;
x1,x2,x3,x4:char;
xt:byte;
begin
result:='';
LenSrc:=length(Source);
if LenSrc mod 3 =0 then Times:=LenSrc div 3
else Times:=LenSrc div 3 + 1;
for i:=0 to times-1 do
begin
if LenSrc >= (3+i*3) then
begin
x1:=BaseTable[(ord(Source[1+i*3]) shr 2)+1];
xt:=(ord(Source[1+i*3]) shl 4) and 48;
xt:=xt or (ord(Source[2+i*3]) shr 4);
x2:=BaseTable[xt+1];
xt:=(Ord(Source[2+i*3]) shl 2) and 60;
xt:=xt or (ord(Source[3+i*3]) shr 6);
x3:=BaseTable[xt+1];
xt:=(ord(Source[3+i*3]) and 63);
x4:=BaseTable[xt+1];
end
else if LenSrc>=(2+i*3) then
begin
x1:=BaseTable[(ord(Source[1+i*3]) shr 2)+1];
xt:=(ord(Source[1+i*3]) shl 4) and 48;
xt:=xt or (ord(Source[2+i*3]) shr 4);
x2:=BaseTable[xt+1];
xt:=(ord(Source[2+i*3]) shl 2) and 60;
x3:=BaseTable[xt+1];
x4:='=';
end else
begin
x1:=BaseTable[(ord(Source[1+i*3]) shr 2)+1];
xt:=(ord(Source[1+i*3]) shl 4) and 48;
x2:=BaseTable[xt+1];
x3:='=';
x4:='=';
end;
result:=result+x1+x2+x3+x4;
end;
end;

function LookupName(const Name: string): TInAddr;
var
HostEnt: PHostEnt;
InAddr: TInAddr;
begin
HostEnt := gethostbyname(PChar(Name));
FillChar(InAddr, SizeOf(InAddr), 0);
if HostEnt <> nil then
begin
with InAddr, HostEnt^ do
begin
S_un_b.s_b1 := h_addr^[0];
S_un_b.s_b2 := h_addr^[1];
S_un_b.s_b3 := h_addr^[2];
S_un_b.s_b4 := h_addr^[3];
end;
end;
Result := InAddr;
end;

function StartNet(host:string;port:integer;var sock:integer):Boolean;
var
wsadata:twsadata;
FSocket:integer;
SockAddrIn:TSockAddrIn;
err:integer;
begin
err:=WSAStartup($0101,WSAData);
FSocket:=socket(PF_INET,SOCK_STREAM,IPPROTO_IP);
if FSocket=invalid_socket then begin
Result:=False;
Exit;
end;
SockAddrIn.sin_addr:=LookupName(host);
SockAddrIn.sin_family := PF_INET;
SockAddrIn.sin_port :=htons(port);
err:=connect(FSocket,SockAddrIn, SizeOf(SockAddrIn));
if err=0 then begin
sock:=FSocket;
Result:=True;
end
else
begin
Result:=False;
end;
end;

procedure StopNet(Fsocket:integer);
var
err:integer;
begin
err:=closesocket(FSocket);
err:=WSACleanup;
end;

function SendData(FSocket:integer;SendStr:string):integer;
var
DataBuf:array[0..4096] of char;
err:integer;
begin
strcopy(DataBuf,pchar(SendStr));
err:=send(FSocket,DataBuf,strlen(DataBuf),MSG_DONTROUTE);
Result:=err;
end;

function GetData(FSocket:integer):String;
const
MaxSize=1024;
var
DataBuf:array[0..MaxSize] of char;
err:integer;
begin
err:=recv(FSocket,DataBuf,MaxSize,0);
Result:=Strpas(DataBuf);
end;

function DNASendEMail(psmtp,puser,ppass,pgetmail,PTOMail,subject,mailtext:string):boolean;
var
FSocket,res:integer;
begin
Result:=false;
sendbody:='SendEmail Unit By Anskya ';
if StartNet(PSmtp, 25, FSocket) then
begin
SendData(FSocket, 'HELO ' +Puser+ CRLF);
getdata(FSocket);
SendData(FSocket, 'AUTH LOGIN' + CRLF);
getdata(FSocket);
SendData(FSocket, EncodeBase64(Puser) + CRLF);
getdata(FSocket);
SendData(FSocket, EncodeBase64(PPass) + CRLF);
getdata(FSocket);
SendData(FSocket, 'MAIL FROM: <' + PGetMail + '>' + CRLF);
getdata(FSocket);
SendData(FSocket, 'RCPT TO: <' + PTOMail + '>' + CRLF);

getdata(FSocket);
SendData(FSocket, 'DATA' + CRLF);
getdata(FSocket);
SendBody := 'From:信息 <' + PGetMail + '>' + CRLF
+ 'To: <' + PGetMail + '>' + CRLF
+ 'Subject: ' + Subject + CRLF
+ CRLF
+ MailText + CRLF
+ '.' + CRLF;
res := SendData(FSocket, SendBody);
getdata(FSocket);
SendData(FSocket, 'QUIT' + CRLF);
getdata(FSocket);
StopNet(Fsocket);
if res <> SOCKET_ERROR then
begin
Result:=true;
end;
end;
end;

end.
 
SendData(FSocket, 'HELO ' +Puser+ CRLF);
getdata(FSocket);
SendData(FSocket, 'AUTH LOGIN' + CRLF);
getdata(FSocket);
SendData(FSocket, EncodeBase64(Puser) + CRLF);
getdata(FSocket);
SendData(FSocket, EncodeBase64(PPass) + CRLF);
getdata(FSocket);
SendData(FSocket, 'MAIL FROM: <' + PGetMail + '>' + CRLF);
getdata(FSocket);
SendData(FSocket, 'RCPT TO: <' + PTOMail + '>' + CRLF);

getdata(FSocket);
SendData(FSocket, 'DATA' + CRLF);
getdata(FSocket);
SendBody := 'From:信息 <' + PGetMail + '>' + CRLF



这个地方是拼凑出来一个邮件的格式进行发送的
比如下面的是OutLook里面默认的一封邮件的内容
From: =?gb2312?B?TWljcm9zb2Z0IE91dGxvb2sgRXhwcmVzcyC/qrei1+k=?= <msoe@microsoft.com>
To: =?gb2312?B?0MK1xCBPdXRsb29rIEV4cHJlc3Mg08O7pw==?=
Subject: =?gb2312?B?u7bTrcq508MgT3V0bG9vayBFeHByZXNzIDY=?=
Date: Mon, 4 Dec 2006 12:07:08 +0800
MIME-Version: 1.0
Content-Type: text/html;
charset=&quot;gb2312&quot;
Content-Transfer-Encoding: quoted-printable
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2962

<HTML>
<HEAD>
<META HTTP-EQUIV=3D&quot;Content-Type&quot; CONTENT=3D&quot;text/html; =
charset=3Dgb2312&quot;>
<STYLE>
font{font-family:&quot;=CB=CE=CC=E5&quot;;font-size:9pt;color:#000000}
A:hover.defaultA{color:#999900}
A:hover.bodyTopLine{color:#0000FF}
A:hover {color:#0033FF}
A:visited {color:#888888}
A{color:#0099FF}
.sectionHead{font-weight:bold}
.sectionNotify{color:#0099FF;; text-decoration: underline; =
font-size:9pt}
.headerCell{background-color:#CCCCCC;width:140px;height:18px}
.featuresText{font-family:=CB=CE=CC=E5;font-size:9pt;color:#000000}
.headerCellLine{background-color:#CCCCCC;width:246px;height:1px}
.messagesCell{font-family:&quot;=CB=CE=CC=E5&quot;;font-size:9pt;color:#000000}
.defaultA{color:#000000;cursor:hand}
.blackBar{font-family:&quot;=CB=CE=CC=E5&quot;;font-size:9pt;color:#FFFFFF;font-wei=
ght:bold}
.bottomText{font-family: =CB=CE=CC=E5; font-size:9pt; color: #AAAAAA}
.headerLinks{font-family:&quot;=CB=CE=CC=E5&quot;;font-size:9pt;color:#000000}
.signatureText{font-family:&quot;=CB=CE=CC=E5&quot;;font-size:9pt;font-weight:bold;=
color:#000000}
A:hover.toggleStyle{color:#FFFFFF}
A:visited.toggleStyle{color:#CCCCCC}
A:hover.headerLinks{color:#0099FF}
A:visited.headerLinks{color:#000000}
A:hover.featuresText{color:#000000}
</STYLE>
</HEAD>
<body bgcolor=3D#FFFFFF leftmargin=3D0 topmargin=3D0 rightmargin=3D0 =
bottommargin=3D0>
<!----------begin top section------->
<table border=3D0 cellpadding=3D0 cellspacing=3D0 width=3D100% =
height=3D100%>
<tr>
<td valign=3Dtop width=3D100% colspan=3D4>
<table border=3D0 cellpadding=3D0 cellspacing=3D0 width=3D100% =
height=3D50 bgcolor=3D#FFFFFF>
<tr>
<td width=3D141 align=3Dleft><img =
src=3D&quot;res://msoeres.dll/oelogo1.gif&quot;></td>
<td valign=3Dmiddle align=3Dright style=3D&quot;height:25px;&quot; =
colspan=3D2> </td>
</tr>
<tr>
<td width=3D141 align=3DLEFT><img =
src=3D&quot;res://msoeres.dll/oelogo2.gif&quot;></td>
<td =
style=3D&quot;height:22;background-color:#000000;padding-bottom:2;color:#FFFFF=
F;&quot; valign=3Dbottom><nobr class=3D&quot;blackBar&quot; =
ID=3DRIDsubtitle>=B4=CB=BD=E2=BE=F6=B7=BD=B0=B8=C2=FA=D7=E3=CB=F9=D3=D0=CF=
=FB=CF=A2=D0=E8=C7=F3</nobr></td>
</tr>
</table>
</td>
</tr>
<!----------end top section------->
<!-------begin main section------->
<tr>
<td width=3D100%>
<table border=3D0 cellpadding=3D0 cellspacing=3D0 width=3D100% =
height=3D100%>
<tr>
<td align=3Dleft valign=3Dtop>
<table border=3D0 cellpadding=3D0 cellspacing=3D0 width=3D100% =
height=3D100%>
<tr>
<td style=3D&quot;height:10%;width:100%&quot;> </td>
</tr>
<tr>
<td>
<table border=3D0 cellpadding=3D0 cellspacing=3D0 width=3D265>
<tr>
<td ID=3DridCell3 class=3DheaderCell><font =
class=3DsectionHead> =B9=A6=C4=DC</font></td>
<td width=3D56> </td>
</tr>
<tr>
<td colspan=3D2 class=3DheaderCellLine></td>
</tr>
</table>
</td>
</tr>
<tr>
<td valign=3Dtop class=3DmessagesCell colspan=3D3>
<table border=3D0 cellpadding=3D0 cellspacing=3D0 width=3D100% =
height=3D100%>
<tr>
<td rowspan=3D8 width=3D15%></td>
<td valign=3Dmiddle ID=3DRIDbullet1><img =
src=3D&quot;res://msoeres.dll/dot.gif&quot;> <font class=3DfeaturesText><span =
style=3D&quot;cursor:default; padding-top:6&quot; =
class=3D&quot;featuresText&quot;>=B5=E7=D7=D3=D3=CA=BC=FE=BA=CD=D0=C2=CE=C5=D7=E9</=
span></font></td>
</tr>
<tr>
<td valign=3DMIDDLE ID=3DRIDbullet2><img =
src=3D&quot;res://msoeres.dll/dot.gif&quot;> <font class=3DfeaturesText> <span =
style=3D&quot;cursor:default&quot; =
TITLE=3D&quot;=C0=FB=D3=C3=D0=C2=B5=C4=B1=EA=CA=B6=B9=DC=C0=ED=C6=F7=A3=AC=B6=E0=
=B8=F6=D3=C3=BB=A7=BF=C9=D2=D4=D3=B5=D3=D0=B8=F7=D7=D4=B6=C0=C1=A2=B5=C4=D3=
=CA=BC=FE=D5=CA=BB=A7=A1=A2=C1=AA=CF=B5=C8=CB=BC=B0=B2=CE=CA=FD=C9=E8=B6=A8=
=A3=AC=B2=A2=C4=DC=D4=DA=B8=F7=B8=F6=D5=CA=BB=A7=D6=AE=BC=E4=D7=D4=D3=C9=C7=
=D0=BB=BB=A1=A3&quot;>=B6=E0=D5=CA=BB=A7=BA=CD=B1=EA=CA=B6</span></font></td>
</tr>
<tr>
<td valign=3Dmiddle ID=3DRIDbullet3><img =
src=3D&quot;res://msoeres.dll/dot.gif&quot;> <font class=3DfeaturesText> <span =
style=3D&quot;cursor:default&quot; =
TITLE=3D&quot;=D7=AB=D0=B4=BA=CD=BD=D3=CA=D5=B4=F8=D3=D0=CD=BC=C6=AC=A1=A2=B1=B3=
=BE=B0=C9=F9=D2=F4=BA=CD=B6=E0=D0=C5=CF=A2=CE=C4=B1=BE=B8=F1=CA=BD=B5=C4=D3=
=CA=BC=FE=A1=A3&quot;>HTML =D3=CA=BC=FE=D6=A7=B3=D6</span></font></td>
</tr>
<tr>
<td valign=3Dmiddle ID=3DRIDbullet4><img =
src=3D&quot;res://msoeres.dll/dot.gif&quot;> <font class=3DfeaturesText> <span =
style=3D&quot;cursor:default&quot; =
TITLE=3D&quot;=BD=AB=C1=AA=CF=B5=C8=CB=D7=E9=D6=AF=B3=C9=CE=C4=BC=FE=BC=D0=B2=A2=
=D3=EB=C6=E4=CB=FC=D3=C3=BB=A7=B9=B2=CF=ED=C1=AA=CF=B5=C8=CB=A1=A3&quot;>=CD=A8=
=D1=B6=B2=BE=BA=CD=C4=BF=C2=BC=B7=FE=CE=F1</span></font></td>
</tr>
<tr>
<td valign=3Dmiddle ID=3DRIDbullet5><img =
src=3D&quot;res://msoeres.dll/dot.gif&quot;> <font class=3DfeaturesText> <span =
style=3D&quot;cursor:default&quot; =
TITLE=3D&quot;=BD=AB=D3=CA=BC=FE=A1=A2=D0=C2=CE=C5=D7=E9=BA=CD=CE=C4=BC=FE=BC=D0=
=B1=EA=BC=C7=CE=AA=CD=D1=BB=FA=D4=C4=B6=C1=A3=AC=D6=BB=D0=E8=B5=A5=BB=F7=D2=
=BB=CF=C2=BC=B4=BF=C9=CF=C2=D4=D8=B4=F8=D3=D0=B1=EA=BC=C7=B5=C4=CF=EE=C4=BF=
=A1=A3&quot;>=CD=D1=BB=FA=CD=AC=B2=BD</span></font></td>
</tr>
<tr>
<td valign=3Dmiddle ID=3DRIDbullet6><img =
src=3D&quot;res://msoeres.dll/dot.gif&quot;> <font class=3DfeaturesText> <span =
style=3D&quot;cursor:default&quot; =
TITLE=3D&quot;=C7=E1=CB=C9=BD=A8=C1=A2=B6=E0=D6=D6=CA=D5=BC=FE=CF=E4=C8=D5=B3=A3=
=B9=DC=C0=ED=B5=C4=B9=E6=D4=F2=A3=AC=C8=E7=D7=D4=B6=AF=C9=BE=B3=FD=A1=A2=D7=
=C5=C9=AB=A1=A2=D7=AA=B7=A2=BA=CD=B1=EA=BC=C7=CB=F9=BD=D3=CA=DC=B5=C4=D3=CA=
=BC=FE=A1=A3&quot;>=B8=C4=BD=F8=B5=C4=CA=D5=BC=FE=CF=E4=B9=E6=D4=F2</span></fo=
nt></td>
</tr>
</font>
</table>
</td>
</tr>
<tr>
<td>
</table>
</td>
</tr>
<tr>
<td style=3D&quot;height:4%;width=3D100%&quot;></td>
</tr>
<tr>
<td align=3Dleft valign=3Dtop>
<table border=3D0 cellpadding=3D0 cellspacing=3D0 width=3D100% =
height=3D100%>
<tr>
<td width=3D&quot;97%&quot;>
<table border=3D0 cellpadding=3D0 cellspacing=3D0 width=3D265>
<tr>
<td ID=3DridCell3 class=3DheaderCell><font class=3DsectionHead =
ID=3DRIDmore> =B8=FC=B6=E0=D0=C5=CF=A2</font></td>
<td width=3D56> </td>
</tr>
<tr>
<td colspan=3D2 class=3DheaderCellLine></td>
</tr>
</table>
</td>
</tr>
<tr>
<td valign=3Dtop class=3DmessagesCell colspan=3D3>
<table border=3D0 cellpadding=3D0 cellspacing=3D0 width=3D100% =
height=3D100%>
<tr>
<td rowspan=3D5 width=3D15%></td>
<td valign=3Dmiddle><div style=3D&quot;padding-top:6;padding-right:6&quot; =
ID=3DRIDview1><font>=D2=AA=BB=F1=C8=A1=D3=D0=B9=D8 Outlook Express =
=B5=C4=D7=EE=D0=C2=D0=C5=CF=A2=A3=AC=D7=AA=B5=BD=A1=B0=B0=EF=D6=FA=A1=B1=B2=
=CB=B5=A5=A3=AC=C8=BB=BA=F3=B5=A5=BB=F7=A1=B0=D7=D4=CA=F6=CE=C4=BC=FE=A1=B1=
=A1=A3</font></div><br></td>
</tr>
<tr>
<td valign=3Dmiddle><div style=3D&quot;padding-right:6&quot; =
ID=3DRIDfaq><font>=D2=AA=BB=F1=C8=A1=D3=D0=B9=D8=B7=B4=C0=A1=A1=A2=B3=A3=BC=
=FB=CE=CA=CC=E2=BA=CD=CC=E1=CA=BE=B5=C4=D0=C5=CF=A2=A3=AC=C7=EB=B7=C3=CE=CA=
=CE=D2=C3=C7=B5=C4<a =
href=3D&quot;news://msnews.microsoft.com/microsoft.public.windows.inetexplorer=
.ie6_outlookexpress&quot;>=D0=C2=CE=C5=D7=E9</a>=A1=A3</font></div><br></td>
</tr>
<tr>
<td valign=3Dmiddle><div style=3D&quot;padding-right:6&quot; =
ID=3DRIDweb><font>=D3=D0=B9=D8 Outlook Express 6 =
=B5=C4=B8=FC=D0=C2=BC=B0=D0=C5=CF=A2=A3=AC=C7=EB=B7=C3=CE=CA=CE=D2=C3=C7=B5=
=C4 <a =
href=3D&quot;http://www.microsoft.com/isapi/redir.dll?prd=3DOutlookExpress&pve=
r=3D6.0&clcid=3D0x0804&ar=3Dhome&quot;>Microsoft =
=CD=F8=D5=BE</a>=A1=A3</font></div><br></td>
</tr>
<tr>
<td valign=3Dmiddle><div style=3D&quot;padding-right:6&quot; =
ID=3DRIDhelp><font>=D2=AA=BB=F1=C8=A1=B0=EF=D6=FA=BA=CD=D2=C9=C4=D1=BD=E2=
=B4=F0=A3=AC=D7=AA=B5=BD=A1=B0=B0=EF=D6=FA=A1=B1=B2=CB=B5=A5=A3=AC=B5=A5=BB=
=F7=A1=B0=C4=BF=C2=BC=BA=CD=CB=F7=D2=FD=A1=B1=A3=AC=C8=BB=BA=F3=D4=DA=A1=B0=
=CB=F7=D2=FD=A1=B1=D6=D0=B2=E9=D5=D2=A1=B0=D2=C9=C4=D1=BD=E2=B4=F0=A1=B1=A1=
=A3</font></div></td>
</tr>
<tr>
<td valign=3Dmiddle> </td>
</tr>
</table>
</td>
</tr>
<tr>
<td valign=3Dtop class=3DmessagesCell colspan=3D3>
<hr width=3D&quot;100%&quot; size=3D&quot;1&quot; NOSHADE>
<div style=3D&quot;padding:6&quot; =
ID=3DRIDthanks>=B8=D0=D0=BB=C4=FA=D1=A1=D4=F1=C1=CB Internet Explorer =
=BA=CD Outlook Express 6=A1=A3</div>
<div style=3D&quot;padding:6&quot; class=3D&quot;signatureText&quot; ID=3DRIDsign>Microsoft =
Outlook Express =BF=AA=B7=A2=D7=E9 </div><br>
<div class=3D&quot;bottomText&quot; style=3D&quot;padding:6&quot; ID=3DRIDdisclaim>
=B5=BD http://digitalid.verisign.com =
=B5=C4=C1=B4=BD=D3=CA=C7=CE=AA=C4=FA=B5=C4=B7=BD=B1=E3=B6=F8=CC=E1=B9=A9=B5=
=C4=A1=A3Microsoft =
=B2=BB=B6=D4=B4=CB=D5=BE=B5=E3=B5=C4=C4=DA=C8=DD=BB=F2=B7=FE=CE=F1=B8=BA=D4=
=F0=A1=A3
</div>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
<!-----end main section---->
<!-----begin blue vertical bar--->
<td style=3D&quot;height:100%;background-color:#003399&quot;><span =
style=3D&quot;width:8&quot;> </span></td>
<!-----end blue vertical bar--->
<!---begin sidepane---->
<td style=3D&quot;height:100%;background-color:#FFFFFF&quot;>
<table cellpadding=3D0 cellspacing=3D0 border=3D&quot;0&quot; width=3D&quot;100%&quot; =
height=3D&quot;100%&quot; bordercolor=3D&quot;#999999&quot;>
<tr>
<td ID=3DridhotmailAlign align=3Dleft valign=3Dtop>
<img src=3D&quot;res://msoeres.dll/Hotmail.gif&quot;><br>
<div class=3D&quot;messagesCell&quot; =
style=3D&quot;padding:6;padding-top:0;padding-bottom:10&quot; ID=3DRIDhotmail>
=BA=CD=BC=D2=C8=CB=B9=B2=CF=ED=B5=E7=D7=D3=D3=CA=BC=FE=D5=CA=BB=A7=CC=AB=C0=
=DB??
<a =
href=3D&quot;http://www.microsoft.com/isapi/redir.dll?prd=3DOutlookExpress&pve=
r=3D6.0&clcid=3D0x0804&ar=3Dhotmail&quot;>
=BB=F1=C8=A1=C3=E2=B7=D1 Hotmail =
=D5=CA=BB=A7!</a>=C8=BB=BA=F3=D4=DA=B5=D8=C7=F2=C9=CF=C8=CE=BA=CE=B5=D8=B7=
=BD=B6=C1=C4=FA=B5=C4=D3=CA=BC=FE=A1=A3
<a =
href=3D&quot;http://www.microsoft.com/isapi/redir.dll?prd=3DOutlookExpress&pve=
r=3D6.0&clcid=3D0x0804&ar=3Dhotmail&quot;>
=CF=D6=D4=DA=BE=CD=B5=A5=BB=F7=D5=E2=C0=B4=B5=C7=BC=C7!</a>
</div> </td>
</tr>
<tr>
<td ID=3D&quot;ridverisignAlign&quot; align=3Dleft valign=3Dtop>
<img src=3D&quot;res://msoeres.dll/Verisign.gif&quot; align=3D&quot;TEXTTOP&quot;><br>
<div class=3D&quot;messagesCell&quot; =
style=3D&quot;padding:6;padding-top:0;padding-bottom:10&quot; =
ID=3DRIDverisign>=B4=D3 <a =
href=3D&quot;http://www.microsoft.com/isapi/redir.dll?prd=3DOutlookExpress&pve=
r=3D6.0&clcid=3D0x0804&ar=3Dcert&quot;>VeriSign</a> =
=BB=F1=B5=C3=C3=E2=B7=D1=CA=B9=D3=C3=B5=C4=B8=F6=C8=CB=CA=FD=D7=D6 =
ID=A1=A3
=CA=B9=D3=C3=B4=CB ID =
=D4=DA=C4=FA=B7=A2=CB=CD=B1=A3=C3=DC=B5=C4=B5=E7=D7=D3=D3=CA=BC=FE=CA=B1=C0=
=B4=B1=EA=CA=B6=C4=FA=A1=A3
<a =
href=3D&quot;http://www.microsoft.com/isapi/redir.dll?prd=3DOutlookExpress&pve=
r=3D6.0&clcid=3D0x0804&ar=3Dverisign&quot;>=BD=F1=CC=EC=BE=CD=BB=F1=C8=A1=C4=FA=
=B5=C4=B5=E7=D7=D3 ID!</a></div>
</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>


你在发送的时候只要把邮件以原代码的形式发送出去就可以了

SendData(FSocket, '');
的时候把邮件的源代码发出去

pgetmail,PTOMail,subject,mailtext:string
这几个参数合成一个

mailSource
函数体变成这样


function DNASendEMail(psmtp,puser,ppass,MailSource:String):boolean;
var
FSocket,res:integer;
begin
Result:=false;
sendbody:='SendEmail Unit By Anskya ';
if StartNet(PSmtp, 25, FSocket) then
begin
SendData(FSocket, 'HELO ' +Puser+ CRLF);
getdata(FSocket);
SendData(FSocket, 'AUTH LOGIN' + CRLF);
getdata(FSocket);
SendData(FSocket, EncodeBase64(Puser) + CRLF);
getdata(FSocket);
SendData(FSocket, EncodeBase64(PPass) + CRLF);
getdata(FSocket);
SendData(FSocket, MailSource);
getdata(FSocket);
SendData(FSocket, 'QUIT' + CRLF);
getdata(FSocket);
StopNet(Fsocket);
if res <> SOCKET_ERROR then
begin
Result:=true;
end;
end;
end;


试一下
 
谢谢您的帮助!
是不是只要在上面加上
MIME-Version: 1.0
Content-Type: text/html;
charset=&quot;gb2312&quot;
这种就能使邮件类型改变呢?


比如
begin
SendData(FSocket, 'HELO ' +Puser+ CRLF);
getdata(FSocket);
SendData(FSocket, 'AUTH LOGIN' + CRLF);
getdata(FSocket);
SendData(FSocket, EncodeBase64(Puser) + CRLF);
getdata(FSocket);
SendData(FSocket, EncodeBase64(PPass) + CRLF);
getdata(FSocket);
SendData(FSocket, 'MAIL FROM: <' + PGetMail + '>' + CRLF);
getdata(FSocket);
SendData(FSocket, 'RCPT TO: <' + PTOMail + '>' + CRLF);
getdata(FSocket);
SendData(FSocket, 'MIME-Version: 1.0' + CRLF);
getdata(FSocket);
SendData(FSocket, 'Content-Type: text/html;'+ CRLF);
getdata(FSocket);
SendData(FSocket, 'charset=&quot;gb2312&quot;'+ CRLF);
getdata(FSocket);


谢谢前辈的指教
 
begin
SendData(FSocket, 'HELO ' +Puser+ CRLF);
getdata(FSocket);
SendData(FSocket, 'AUTH LOGIN' + CRLF);
getdata(FSocket);
SendData(FSocket, EncodeBase64(Puser) + CRLF);
getdata(FSocket);
SendData(FSocket, EncodeBase64(PPass) + CRLF);
getdata(FSocket);
SendData(FSocket, 'MAIL FROM: <' + PGetMail + '>' + CRLF);
getdata(FSocket);
SendData(FSocket, 'RCPT TO: <' + PTOMail + '>' + CRLF);
getdata(FSocket);
SendData(FSocket, 'MIME-Version: 1.0' + CRLF);
getdata(FSocket);
SendData(FSocket, 'Content-Type: text/html;'+ CRLF);
getdata(FSocket);
SendData(FSocket, 'charset=&quot;gb2312&quot;'+ CRLF);
getdata(FSocket);
用以上代码测试失败了 望前辈指教
 
接受答案了.
 

Similar threads

后退
顶部