Forum > Third party
Indy mime boundry problems
(1/1)
Pieter9876:
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:
Seems post should go to http://forum.lazarus.freepascal.org/index.php?board=42.0
Remy Lebeau:
Or http://forum.lazarus.freepascal.org/index.php?board=38.0
Remy Lebeau:
--- Quote from: Pieter9876 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.
--- End quote ---
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.
--- Quote from: Pieter9876 on June 05, 2018, 04:17:41 pm ---I have a email with plain text and html text and an attachment.
--- End quote ---
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
Pieter9876:
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.
Navigation
[0] Message Index