* * *

Author Topic: Indy mime boundry problems  (Read 369 times)

Pieter9876

  • Newbie
  • Posts: 2
Indy mime boundry problems
« on: June 05, 2018, 04:17:41 pm »
If I send an Email width my current Indy solution I can only choose between or Multipart / alternative or Multipart / Mixed
I would like to use the both combined in an Email.

I have a email with plain text and html text and an attachment.

Looking at the raw source of an gmail it should have the following structure.


MIME-Version: 1.0
Received: by 2002:a2e:12dd:0:0:0:0:0 with HTTP; Wed, 30 May 2018 05:31:31 -0700 (PDT)
Date: Wed, 30 May 2018 14:31:31 +0200
Delivered-To: xxxxxxx@gmail.com
Message-ID: <CA+q8OGccoGuocHNL6hU-Lqt9Hixxxxxxx@mail.gmail.com>
Subject: fgfgf
From: Test123 Test123 <xxxxxx@gmail.com>
To: Test123 Test123 <xxxxxx@gmail.com>
Content-Type: multipart/mixed; boundary="000000000000d9c184056d6b8736"

--000000000000d9c184056d6b8736
Content-Type: multipart/alternative; boundary="000000000000d9c181056d6b8734"

--000000000000d9c181056d6b8734
Content-Type: text/plain; charset="UTF-8"

gjhgjfjj

--000000000000d9c181056d6b8734
Content-Type: text/html; charset="UTF-8"

<div dir="ltr">gjhgjfjj</div>

--000000000000d9c181056d6b8734--
--000000000000d9c184056d6b8736
Content-Type: image/png; name="scanicoon.png"
Content-Disposition: attachment; filename="scanicoon.png"
Content-Transfer-Encoding: base64
X-Attachment-Id: f_jht3film0

--000000000000d9c184056d6b8736--

----------------------------------------------------------------------------------------------------
As you can see, google creates two boundary codes.
And the Alternative part is nested in the mixed part.

How can I accomplish this with Indy code?
My current solution can only create one boundary code.
I did see that the class MimeBoundary exists.




Alextp

  • Hero Member
  • *****
  • Posts: 630
    • UVviewsoft
Re: Indy mime boundry problems
« Reply #1 on: June 05, 2018, 05:26:07 pm »

Remy Lebeau

  • Sr. Member
  • ****
  • Posts: 406
    • Lebeau Software
Remy Lebeau
Lebeau Software - Owner, Developer
Internet Direct (Indy) - Admin, Developer (Support forum)

Remy Lebeau

  • Sr. Member
  • ****
  • Posts: 406
    • Lebeau Software
Re: Indy mime boundry problems
« Reply #3 on: June 07, 2018, 10:38:58 pm »
If I send an Email width my current Indy solution I can only choose between or Multipart / alternative or Multipart / Mixed
I would like to use the both combined in an Email.

Which version of Indy are you using?  What does your code look like?  I'm guessing you are using Indy 9, because you can definitely create emails with BOTH multipart/alternative AND multipart/mixed in Indy 10, but not so much in Indy 9.

I have a email with plain text and html text and an attachment.

See my blog articles on Indy's website on that very topic:

http://www.indyproject.org/Sockets/Blogs/RLebeau/2005_08_17_A.aspx

http://www.indyproject.org/Sockets/Blogs/RLebeau/20080116.EN.aspx
« Last Edit: June 07, 2018, 10:40:55 pm by Remy Lebeau »
Remy Lebeau
Lebeau Software - Owner, Developer
Internet Direct (Indy) - Admin, Developer (Support forum)

Pieter9876

  • Newbie
  • Posts: 2
Re: Indy mime boundry problems
« Reply #4 on: June 08, 2018, 04:48:01 pm »
Remy, I am honored to having received your reply.
You have pointed me into the right direction.

I have changed the code to the following:
-----------------------------------------------------------------------------------------------------------

  with TIdMessageBuilderHtml.Create do
    try
      PlainText.Text := messagetext_plain;
      Html.Text := messagetext;

       sl := TStringList.Create();

        sl.Delimiter := '|';
        for i := 0 to cid_bijlagen.Count - 1 do
        begin
          sl.DelimitedText := cid_bijlagen.Strings;
          if sl.Count >= 3 then
          begin
          (*
            att := TIdAttachmentFile.Create(m.MessageParts);
            att.StoredPathName := bApp.BijlagenUitDirectory + '\' + sl.Strings[0];
            att.FileName := att.StoredPathName;
            att.ContentID := Format( '<%s>', [sl.Strings[1]] );
            att.ContentType := sl.Strings[2];
            *)

            HtmlFiles.Add(bApp.BijlagenUitDirectory + '\' + sl.Strings[0]);
          end;
        end;
        FreeAndNil( sl );
        for i := 0 to Bijlagen.Count - 1 do
        begin
          HtmlFiles.Add(Bijlagen.Strings);
        end;
     FillMessage(m);
    finally
      Free;
    end;
----------------------------------------------------------------

This has resolved my problem.
I still have to change it furthur to make it more robust.
And I have to findout from my college what to do with the 'cid_' attachments.

 

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads Open Hub project report for Lazarus