Delphi/Indy 10 - Sending a text or HTML email with attachments adds an attachment for the text (body) itself
Asked Answered
W

1

8

For years, we've been using Indy 10 to send emails (text, not HTML) with one or more PDF attached to it and we never had any problem.

Recently (maybe since Tokyo release 3 ?), our customers noticed that the text part of the email (body) is now an attachment and not part of the email itself.

I've searched the Internet for solutions, and everything I tested did not fix this problem.

I tried some of the solutions proposed on StackOverflow by Remy Lebeau with no success.

The body is an attachment

Here's the code (based on a post found on 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) then begin
            builder.Attachments.Add(edFile.Text);
         end;

         builder.FillMessage(msg);
      finally
         builder.Free;
      end;

      msg.From.Name    := 'From name here';
      msg.From.Address := 'From email address here';
      msg.Subject      := edSubject.Text;

      msg.Recipients.EmailAddresses := edEMail.Text;
      // msg.CCList.EmailAddresses     := CCAddresses;
      // msg.BccList.EmailAddresses    := BCCAddresses;

      smtp := TIdSMTP.Create(nil);

      try
         smtp.Host     := 'Host IP here';
         // Smtp.UseTLS   := utNoTLSSupport;
         smtp.Port     := 25;
         // smtp.Username := '';
         // smtp.Password := '';
         // smtp.AuthType := satDefault;

         smtp.Connect();

         try
           smtp.Send(msg);
         finally
           smtp.Disconnect;
         end;

      finally
         smtp.Free();
      end;
   finally
     msg.Free();
   end;

   ShowMessage('EMail with attachment sent.');
end;

RAW data BEFORE our service provider changed something :

X-Spam-Flag: NO
X-Envelope-From: [email protected]
Return-Path: <[email protected]>
Received: from alt44.smtp-out.videotron.ca (alt44.smtp-out.videotron.ca [23.233.128.31])
    by mail124c7.megamailservers.com (8.14.9/8.13.1) with ESMTP id w8IE2EaJ031620
    for <[email protected]>; Tue, 18 Sep 2018 10:02:16 -0400
Received: from STEPHANS (99.99.99.99])
    by Videotron with SMTP
    id 2GZxgRaQACk662GZygKZJC; Tue, 18 Sep 2018 10:02:14 -0400
Message-ID: <[email protected]>
X-Authority-Analysis: v=2.3 cv=I/dLuuog c=1 sm=1 tr=0
 a=dE52as2XWJrk6k5j72Z8kA==:117 a=dE52as2XWJrk6k5j72Z8kA==:17
 a=9DvhAHx2yrWFMPxQWpQA:9 a=ddwX9jWfLaJL_gwCi7EA:9 a=QEXdDO2ut3YA:10
 a=x4g3fk4yahj5Vy8AyNEA:9 a=n3BslyFRqc0A:10 a=QGevMSd5eboA:10
From: "Stephan St-Denis" <[email protected]>
Subject: Sending an email with an attachment
To: [email protected]
Content-Type: multipart/mixed; boundary="sYOn6pS43NerAC6V2swiiWL68DI9=_SoRR"
MIME-Version: 1.0
Date: Tue, 18 Sep 2018 10:02:11 -0400
X-CMAE-Envelope: MS4wfKOiVw8oDz+nXCTnbMSWSKyXaMU478wM3VDSWQBABhzflbVLGHq70qeoq1ROGHLKj2lDQPx1LLDrcmvbcOtrdhj4j8xx2kLFmh3LfsDxgKpXpd44Lyvy
 UHG4KDKHPNZy4UAAlgA05WwJ7eshsOWamzFhqA3QrXuliQNQVttLQNbhbjg2fqOR387/8VrwqftGFg==
X-CTCH-Spam: Unknown
X-CTCH-VOD: Unknown
X-CTCH-RefID: str=0001.0A020201.5BA10569.0015,ss=1,re=0.000,recu=0.000,reip=0.000,vtr=str,vl=0,cl=1,cld=1,fgs=0
X-CSC: 0
X-CHA: v=2.3 cv=TIBrtWta c=1 sm=1 tr=0 a=C7+rQaujYuxIIavLKnSTDg==:117
    a=dE52as2XWJrk6k5j72Z8kA==:17 a=dueAcN81E1cA:10 a=JBFolyDoGHsA:10
    a=9DvhAHx2yrWFMPxQWpQA:9 a=ddwX9jWfLaJL_gwCi7EA:9 a=QEXdDO2ut3YA:10
    a=x4g3fk4yahj5Vy8AyNEA:9 a=n3BslyFRqc0A:10 a=QGevMSd5eboA:10
X-WHL: LR
X-EsetId: 37303A298E2AB560627366

This is a multi-part message in MIME format

--sYOn6pS43NerAC6V2swiiWL68DI9=_SoRR
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline;filename="Attachment"

This is the text that will be sent along with the attached file. This =
email is in text only format and not HTML.

The text should not be attached but should be part of the email.

--sYOn6pS43NerAC6V2swiiWL68DI9=_SoRR
Content-Type: application/pdf;
    name="Embarcadero.pdf"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
    filename="Embarcadero.pdf"
Content-ID: <Embarcadero.pdf>

JVBERi0xLjYKJf////8gd3d3LnN5bmFjdGlzLmNvbQoxIDAgb2JqCjw8Ci9DcmVhdGlvbkRhdGUo
RDoyMDE3MDIxNDE2MjAyMykKL1RpdGxlKENhc19kZV90ZXN0X0NBMS5wZGYpCi9BdXRob3IoTWFj
Q3JhemVlIEluYy4pCi9Qcm9kdWNlcihQREZCb3ggdmVyc2lvbiBpbnRlcm5lIExQQykKL0NyZWF0
b3IoTGVzIFByb2dpY2llbHMgQ29uY2VwdCBpbmMuKQo+PgplbmRvYmoKNSAwIG9iago8PAovTGVu
Z3RoIDMyNTcKPj4Kc3RyZWFtCkJUCi9GMCAxMiBUZgowIDAgMCByZwowIFRjCjE5Ljg0MyA3NjUu
MDAyIFRkCiggICAgPVJFTEVWRSBERSBUUkFOU0FDVElPTj0pIFRqCkVUCkJUCi9GMCAxMiBUZgow
IDAgMCByZwowIFRjCjE5Ljg0MyA3NTMuMDk3IFRkCiggICAgID09VFJBTlNBQ1RJT04gUkVDT1JE
PT0pIFRqCkVUCkJUCi9GMCAxMiBUZgowIDAgMCByZwowIFRjCjE5Ljg0MyA3ND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KL0ZvbnQ8PAovRjAgOCAwIFIKPj4KPj4KZW5kb2JqCnhyZWYKMCAxMAowMDAwMDAwMDAw
IDY1NTM1IGYNCjAwMDAwMDAwMzIgMDAwMDAgbg0KMDAwMDAwNDI4MyAwMDAwMCBuDQowMDAwMDA0
MzU3IDAwMDAwIG4NCjAwMDAwMDM1MjIgMDAwMDAgbg0KMDAwMDAwMDIxMyAwMDAwMCBuDQowMDAw
MDAzNjA3IDAwMDAwIG4NCjAwMDAwMDM5MTEgMDAwMDAgbg0KMDAwMDAwNDA2MiAwMDAwMCBuDQow
MDAwMDA0MjM1IDAwMDAwIG4NCnRyYWlsZXIKPDwKL1NpemUgMTAKL1Jvb3QgOSAwIFIKL0luZm8g
MSAwIFIKL0lEWyg0Mjc4MDY4MDhzZWVkKSg0Mjc4MDY4MDhzZWVkKV0KPj4Kc3RhcnR4cmVmCjQ0
MjYKJSVFT0YK

--sYOn6pS43NerAC6V2swiiWL68DI9=_SoRR--

RAW data AFTER our service provider changed something

X-Spam-Flag: NO
X-Envelope-From: [email protected]
Return-Path: <[email protected]>
Received: from alt14.smtp-out.videotron.ca (alt14.smtp-out.videotron.ca [135.19.0.27])
    by mail141c7.megamailservers.com (8.14.9/8.13.1) with ESMTP id w8JCvhOr015926
    for <[email protected]>; Wed, 19 Sep 2018 08:57:45 -0400
Received: from STEPHANS ([99.99.99.99])
    by Videotron with SMTP
    id 2c34gzZ4bMdc62c35g1R7X; Wed, 19 Sep 2018 08:57:43 -0400
Message-ID: <[email protected]>
X-Authority-Analysis: v=2.3 cv=PoG9kTE3 c=1 sm=1 tr=0
 a=dE52as2XWJrk6k5j72Z8kA==:117 a=dE52as2XWJrk6k5j72Z8kA==:17
 a=9DvhAHx2yrWFMPxQWpQA:9 a=PyNp0P9dkJ191ZjJjSMA:9 a=ddwX9jWfLaJL_gwCi7EA:9
 a=QEXdDO2ut3YA:10 a=x4g3fk4yahj5Vy8AyNEA:9 a=n3BslyFRqc0A:10 a=QGevMSd5eboA:10
From: "Stephan St-Denis" <[email protected]>
Subject: Sending an email with an attachment
To: [email protected]
Content-Type: multipart/mixed; boundary="2oubkSu12F4FBVsrQ1qmkA=_rIo3IvFYNM"
MIME-Version: 1.0
Date: Wed, 19 Sep 2018 08:57:42 -0400
X-CMAE-Envelope: MS4wfBPFtECskEptewv8r0bLuVgVpcybKuamQgK0q+veOE3mDcPmuU0j2BlwRMolPNl4KeDVRtyCVMVmkK8N5jufk8voKnE1l6SnBAVceHp6p6Ohg6KTOIp1
 srRHBcfqKq4iTOHzsbt4HfC5vzAuQXm6H3d2pHYX2JNz8N1Pq6ze3mdvvacTtuYNEbvI0Ny8ev9LrA==
X-CTCH-Spam: Unknown
X-CTCH-VOD: Unknown
X-CTCH-RefID: str=0001.0A02020C.5BA247CA.0005,ss=1,re=0.000,recu=0.000,reip=0.000,vtr=str,vl=0,cl=1,cld=1,fgs=0
X-CSC: 0
X-CHA: v=2.3 cv=feyDNXYF c=1 sm=1 tr=0 a=csAb9/S9F4eoTzVqV71Dmw==:117
    a=dE52as2XWJrk6k5j72Z8kA==:17 a=WrA80cmexyYA:10 a=JBFolyDoGHsA:10
    a=9DvhAHx2yrWFMPxQWpQA:9 a=PyNp0P9dkJ191ZjJjSMA:9 a=ddwX9jWfLaJL_gwCi7EA:9
    a=QEXdDO2ut3YA:10 a=x4g3fk4yahj5Vy8AyNEA:9 a=n3BslyFRqc0A:10
    a=QGevMSd5eboA:10
X-WHL: LR
X-EsetId: 37303A298E2AB560627264

This is a multi-part message in MIME format

--2oubkSu12F4FBVsrQ1qmkA=_rIo3IvFYNM
Content-Type: multipart/alternative;
    boundary="DhsioUcQxViR3rGTk=_q17PSufSL3rps7M"

--DhsioUcQxViR3rGTk=_q17PSufSL3rps7M
Content-Type: text/plain
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

An HTML viewer is required to see this message

--DhsioUcQxViR3rGTk=_q17PSufSL3rps7M
Content-Type: text/html; charset="utf-8"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

This is the text that will be sent along with the attached file. This =
email is in text only format and not HTML.

The text should not be attached but should be part of the email.

--DhsioUcQxViR3rGTk=_q17PSufSL3rps7M--

--2oubkSu12F4FBVsrQ1qmkA=_rIo3IvFYNM
Content-Type: application/pdf;
    name="Embarcadero.pdf"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
    filename="Embarcadero.pdf"
Content-ID: <Embarcadero.pdf>

JVBERi0xLjYKJf////8gd3d3LnN5bmFjdGlzLmNvbQoxIDAgb2JqCjw8Ci9DcmVhdGlvbkRhdGUo
RDoyMDE3MDIxNDE2MjAyMykKL1RpdGxlKENhc19kZV90ZXN0X0NBMS5wZGYpCi9BdXRob3IoTWFj
Q3JhemVlIEluYy4pCi9Qcm9kdWNlcihQREZCb3ggdmVyc2lvbiBpbnRlcm5lIExQQykKL0NyZWF0
b3IoTGVzIFByb2dpY2llbHMgQ29uY2VwdCBpbmMuKQo+PgplbmRvYmoKNSAwIG9iago8PAovTGVu
Z3RoIDMyNTcKPj4Kc3RyZWFtCkJUCi9GMCAxMiBUZgowIDAgMCByZwowIFRjCjE5Ljg0MyA3NjUu
MDAyIFRkCiggICAgPVJFTEVWRSBERSBUUkFOU0FDVElPTj0pIFRqCkVUCkJUCi9GMCAxMiBUZgow
IDAgMCByZwowIFRjCjE5Ljg0MyA3NTMuMDk3IFRkCiggICAgID09VFJBTlNBQ1RJT04gUkVDT1JE
PT0pIFRqCkVUCkJUCi9GMCAxMiBUZgowIDAgMCByZwowIFRjCjE5Ljg0MyA3NDAuOTA4IFRkCihU
UFYyMjAzNjIzOSAgICAgICAgTUFSQ0g1MDAwMjEwNSkgVGoKRVQKQlQKL0YwIDEyIFRmCjAgMCAw
IHJnCjAgVGMKMTkuODQzIDcyOS4wMDIgVGQKKFBST0dJQ0lFTFMgQ09OQ0VQVCkgVGoKRVQKQlQK
L0YwIDEyIFRmCjAgMCAwIHJnCjAgVGMKMTkuODQzIDcxNy4wOTcgVGQKKDIyMTgsQ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AwMDAwIG4NCjAwMDAwMDM5MTEgMDAwMDAgbg0KMDAwMDAwNDA2MiAwMDAwMCBuDQow
MDAwMDA0MjM1IDAwMDAwIG4NCnRyYWlsZXIKPDwKL1NpemUgMTAKL1Jvb3QgOSAwIFIKL0luZm8g
MSAwIFIKL0lEWyg0Mjc4MDY4MDhzZWVkKSg0Mjc4MDY4MDhzZWVkKV0KPj4Kc3RhcnR4cmVmCjQ0
MjYKJSVFT0YK

--2oubkSu12F4FBVsrQ1qmkA=_rIo3IvFYNM--
Welkin answered 18/9, 2018 at 14:41 Comment(9)
Can't reproduce, and I see nothing wrong with the code. Please show the raw email data that TIdMessage is actually generating. I suspect the problem is going to be on the receiver's end instead (buggy reader, etc)Phylis
Thank you Remy for your precious time and for answering my question. This morning, I sent myself an email in order to show you the RAW email data and I don't know what happened during the night, but the body is now shown correctly (not attached to the message). It looks like our service provider changed something on their side during the night (software update ?). Many of our customers have the same provider. Could it be related ? Probably. I'll show you the RAW data of the same email before and after the change.Welkin
After contacting one of our customers who have the same service provider, it seems that the problem have been solved during the night. They sent us an email and everything is OK. We spent countless hours on this case. Thank you again for your help.Welkin
in your first example, the plain text's Content-Disposition has a filename attribute that doesn't belong. In your second example, that attribute is missingPhylis
Remy - Exactly. The first example was before our service provider modified something. The second example is the exact same email, but sent the day after. Strange isn't it ? Thanks again for your precious time.Welkin
I'm voting to close this question since it can't be reproduced anymorePhylis
I'm having a very similar problem. I'm studying the above example. I do think another blog post on the correct use of TIdMessageBuilderHtml would be great on the indy blog. It does appear very difficult to see what can be generated and accepted by most email clients.Judenberg
@RemyLebeau: The problem is reproducable with Microsoft Mail. I have a multipart/alternative message. When Content-Disposition: inline is added to the textparts (IdMessageClient.SendBody does this), Mail shows two ATT000 attachments (one for the plaintext part, one for the html part). Microsoft Mail is extremely picky about Content-Disposition. A mail send with Outlook 2016 for example will not show inline images because the "Content-Disposion: inline" is missing for that image attachment.Lightfooted
I created a class based on your example. I use it and have no problems. It works very well.Flake
L
0

We have the same sort of problem with Microsoft Mail. It is caused by the "Content-Disposition: inline" line in the text part which causes MS Mail to show the text part as a downloadable attachment. Removing the Content-Disposition line fixes this but requires you to modify TIdMessageClient.SendBody. Frankly I think MS Mail is to blame.

Lightfooted answered 3/3, 2020 at 20:30 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.