IdSMTP发邮件,内容不能加http

沙滩脚印 2013-01-23 11:42:27
IdSMTP发HTML邮件,内容有http链接就收不到信,
不加http就可以,各位大侠这是怎么回事啊?


IdSMTP1.Host:=Trim(edt1.text);
IdSMTP1.Port:=StrToInt(Trim(edt2.text));
IdSMTP1.Username:=Trim(edt3.text);
IdSMTP1.Password:=Trim(edt4.text);

idmsg1.Priority:=mpHigh;
idmsg1.From.Address := Trim(edt3.text);
idmsg1.Recipients.EMailAddresses := Trim(edt6.text);
idmsg1.CharSet:='GB2312';
idmsg1.ContentType := 'text/html; charset="GB2312"';
idmsg1.From.Name:='张三';
idmsg1.Subject:=Trim(edt5.text);

idmsg1.Body.Add('<html>');
idmsg1.Body.Add('<head>');
idmsg1.Body.Add('<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=gb2312">');
idmsg1.Body.Add('<title>'+idmsg1.Subject+'</title>');
idmsg1.Body.Add('</head>');
idmsg1.Body.Add('<body>');
for I := 0 to mmo1.Lines.Count-1 do
begin
idmsg1.Body.Add(mmo1.Lines.Strings[i]+'<br>');
end;
idmsg1.Body.Add('</body>');
idmsg1.Body.Add('</html>');

try
try
IdSMTP1.Connect();
IdSMTP1.Authenticate;
if IdSMTP1.Connected then
begin
IdSMTP1.Send(idmsg1);
ShowMessage('发送成功');
end;
except
on e:Exception do
begin
ShowMessage('Error:' + e.Message);
IdSMTP1.Disconnect;
Exit;
end;
end;
finally
IdSMTP1.Disconnect;
end;


发信内容:

图牧脸色难看,惊异地望着金摩的虚影,心中有些发寒。

http://bbs.csdn.net

金摩不是实体,像是传说中的鬼魂,这一类反常的事物,让图牧这种骁勇善战的佣兵都有些发毛,这才退了一步,<font color="#CC0000">想要看看情况再说。</font>

他一退步,石岩立即看出了他发虚,准确的把握住了时机,猎豹一样提着匕首疾冲出去,并且招呼迪雅兰一起动手。

迪雅兰虽然也是有些害怕,但是因为知道那鬼影是被石岩释放出来,这才提着胆子从背后围攻图牧。

...全文
334 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
沙滩脚印 2013-01-23
  • 打赏
  • 举报
回复
引用 1 楼 simonhehe 的回复:
发的时候转一下编码
转成什么样的编码?
simonhehe 2013-01-23
  • 打赏
  • 举报
回复
发的时候转一下编码
沙滩脚印 2013-01-23
  • 打赏
  • 举报
回复
成功了 谢谢
无语孩童 2013-01-23
  • 打赏
  • 举报
回复
sList:TStringList
将邮件内容先添加到sList ,然后运行#4的代码,再运行#5发送邮件!
无语孩童 2013-01-23
  • 打赏
  • 举报
回复
 idmsg1.MessageParts.Clear;
      with TIdText.Create(idmsg1.MessageParts, sList) do
      begin
        ContentType := 'text/html';
        CharSet := 'UTF-8'
      end;
idsmtp2.Send(idmsg1);
无语孩童 2013-01-23
  • 打赏
  • 举报
回复
idmsg1.Encoding := meMIME;

1,593

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 网络通信/分布式开发
社区管理员
  • 网络通信/分布式开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧