小编Pha*_*ult的帖子

Delphi/Indy 10 - 发送带有附件的文本或 HTML 电子邮件会为文本(正文)本身添加一个附件

对于多年来,我们一直在使用印10发送电子邮件(文本,而不是HTML)与连接到它的一个或多个PDF,我们从未有过任何问题。

最近(可能是因为东京发布 3 版?),我们的客户注意到电子邮件(正文)的文本部分现在是附件,而不是电子邮件本身的一部分。

我在互联网上搜索了解决方案,我测试的所有内容都没有解决这个问题。

我尝试了 Remy Lebeau 在 StackOverflow 上提出的一些解决方案,但没有成功。

身体是一个附件

这是代码(基于 StackOverflow 上的帖子)

procedure TForm1.btnSendEmailClick(Sender: TObject);

var
   smtp   : TIdSMTP;
   msg    : TidMessage;
   builder: TIdMessageBuilderHtml;

begin
   msg := TidMessage.Create(nil);

   try
      builder := TIdMessageBuilderHtml.Create();

      try
         // FIsBodyHtml IS FALSE
         if FIsBodyHtml then begin
            builder.Html.Text   := edText.Lines.Text;
            builder.HtmlCharSet := 'utf-8';
            builder.HtmlContentTransfer := 'quoted-printable';
         end else begin
            builder.PlainText.Text := edText.Lines.Text;;
            builder.PlainTextCharSet := 'utf-8';
            builder.PlainTextContentTransfer := 'quoted-printable';
         end;

         // Add attached file here
         if (edFile.Text <> '') and FileExists(edFile.Text) …
Run Code Online (Sandbox Code Playgroud)

delphi email attachment indy10 delphi-10.2-tokyo

6
推荐指数
1
解决办法
2589
查看次数

标签 统计

attachment ×1

delphi ×1

delphi-10.2-tokyo ×1

email ×1

indy10 ×1