TIdSMTP的问题。怎样主动设置邮件体的格式?

孩皮妞野 2002-04-17 11:06:30
没有加附件的时候,当成html, 换行,空格全乱了;加了附件后,又当成纯文本了。

示例代码:

void __fastcall TForm2::Button2Click(TObject *Sender)
{
if(!IdSMTP1->Connected())
IdSMTP1->Connect();
IdMessage1->Body->Assign(Memo1->Lines);
IdMessage1->ContentType = "text/html";
//TIdAttachment * att = new TIdAttachment(IdMessage1->MessageParts,
// "c:\\blabla.txt");
IdSMTP1->Send(IdMessage1);
//delete att;
}


怎样在没有附件的时候以纯文本发送?
怎样在有附件时以HTML发送?
...全文
398 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
wjzhuang 2002-04-18
  • 打赏
  • 举报
回复
Great. I am glad to see you solve this problem.
孩皮妞野 2002-04-18
  • 打赏
  • 举报
回复
呵呵,解决了。

rh, 你的办法果然有效!谢谢了。
孩皮妞野 2002-04-18
  • 打赏
  • 举报
回复
rh, 你能来太好了。

我试一试先。
孩皮妞野 2002-04-17
  • 打赏
  • 举报
回复
都不行啊。

谢谢。
wjzhuang 2002-04-17
  • 打赏
  • 举报
回复
Can we just set the ContentType for TEXT format?

The other possible solution, don't use the Memo component.
Probably it will format your file.


rh 2002-04-17
  • 打赏
  • 举报
回复
真的不可以

我试验了一下
先设置ContentType为HTML
然后加附件
此时确实不可以以html方式显示

但加附件之后再次设置ContentType,就可以了

13,826

社区成员

发帖
与我相关
我的任务
社区描述
C++ Builder相关内容讨论区
社区管理员
  • 基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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