刚刚我测试了,发送成功,收到邮件,是html格式的:
Return-Path: <zqw0117@sina.com>
Delivered-To: zqw0117@mail3-78.sinamail.sina.com.cn
Received: (qmail 84797 invoked from network); 9 Nov 2005 10:30:45 -0000
Received: from unknown (HELO mx3-19.sinamail.sina.com.cn) (10.55.3.19)
by mail3-78.sinamail.sina.com.cn with SMTP; 9 Nov 2005 10:30:45 -0000
Received: (qmail 32269 invoked from network); 9 Nov 2005 10:30:47 -0000
Received: from unknown (HELO smtp.sina.com.cn) (202.108.3.176)
by mx3-19.sinamail.sina.com.cn with SMTP; 9 Nov 2005 10:30:47 -0000
X-sina-Originating-IP:[202.108.3.176]
X-sina-Originating-HELO:[smtp.sina.com.cn]
X-sina-Received-SPF:[pass]
Received: (qmail 50796 invoked from network); 9 Nov 2005 18:30:09 -0000
Received: from unknown (HELO zq) (219.140.202.95)
by smtp.sina.com.cn with SMTP; 9 Nov 2005 18:30:09 -0000
From: "Me" <zqw0117@sina.com>
Subject: Some Subject
To: zqw0117@sina.com
Content-Type: Multipart/Alternative; boundary="dSGTQlen8xSJryBabI8Om=_ZeByQbfBbQM"
MIME-Version: 1.0
Sender: Me <zqw0117@sina.com>
Date: Wed, 9 Nov 2005 18:30:23 +0800
X-Mailer: Foxmail
This is a multi-part message in MIME format
--dSGTQlen8xSJryBabI8Om=_ZeByQbfBbQM
Content-Type: text/plain
Content-Transfer-Encoding: quoted-printable
This is the plain part of the message.
--dSGTQlen8xSJryBabI8Om=_ZeByQbfBbQM
Content-Type: text/html
Content-Transfer-Encoding: quoted-printable
<html> <head><title>The attachment</title> </head>=20
<body> <h2>This is the attached HTML file</h2> </body> </html>=20
--dSGTQlen8xSJryBabI8Om=_ZeByQbfBbQM--
这是邮件体(注意,我是在foxmail里面打开邮件头查看邮件全文显示的).
另外,我用的已经是Indy10了,版本不一样了,我的代码如下:
procedure TForm1.Button1Click(Sender: TObject);
var
idtTextPart:TIdText;
begin
IdMsgSend. Clear;
IdMsgSend.ContentType := 'Multipart/Alternative';
// add a plain text message part
idtTextPart:=TIdText.Create(IdMsgSend.MessageParts,nil);
idtTextPart.ContentType:='text/plain';
idtTextPart.Body.Add('This is the plain part of the message.');
// add the HTML message part
idtTextPart:= TIdText.Create(IdMsgSend.MessageParts,nil);
idtTextPart.ContentType := 'text/html';
idtTextPart.Body.add('');
idtTextPart.Body.add('<html> <head><title>The attachment</title> </head> ');
idtTextPart.Body.add('<body> <h2>This is the attached HTML file</h2> </body> </html> ');
idtTextPart.Body.add('');
// idtTextPart.Body.SaveToFile('c:/abcd.txt');
IdMsgSend.From.Address := 'myemail@domain.com';
IdMsgSend.From.Name := 'Me';
IdMsgSend.Sender.Address := 'myemail@domain.com';
IdMsgSend.Sender.Name := 'Me';
// add the recipients
IdMsgSend.Recipients.clear;
with IdMsgSend.Recipients.Add do Address := 'myemail@domain.com';
IdMsgSend.Subject := 'Some Subject';
// add an attachment
// TIdAttachment.Create(IdMsgSend.MessageParts, 'c:/abcd.txt');
{SMTP Setup}
SMTP.Host := 'smtp.domain.com.cn';
SMTP.Port := 25;
//SMTP.AuthenticationType := atLogin;
SMTP.Username := 'myemail@domain.com';
SMTP.Password := '{已经删除}';
try
try
{now we send the message}
SMTP.Connect;
SMTP.Send(IdMsgSend);
except
on e: Exception do
ShowMessage(e.message);
end;
finally
SMTP.Disconnect;
end;
showmessage('Message Sent');
end;