TIdMessage Content-ID not showing

Giganews Newsgroups
Subject: TIdMessage Content-ID not showing
Posted by:  Vandra_Ákos
Date: Sun, 20 Jul 2008

Hello people!

I have a problem (actually many problems, but these are the ones I
couldn't work around) using TIdMessage.
I have a multipart message containing another multipart message (the
attachments), which should have a Content-ID, so the receiver can
identify which message part has the attachments, and which one the
request. (I don't know if I was clear enough here, but this isn't all
that important really).
My problem is, that I can't make TIdMessage put a Content-ID header for
the embedded multipart messagepart. It simply ignores it. Tried adding
to Header and Extraheaders too.

The other issue is that the generated boundary markers differ only by a
single character at the end (the second one is appended another
character), and the server doesn' like this, it gives internal server
error. If I append another character to the beginning too by hand, it's
solved. But I cannot change the Boundary property of the TIdMessage, it
ignores being given another value.

My code:

    XmlPart := TIdText.Create(Msg.MessageParts,sl);
    XmlPart.ContentType := 'text/xml; charset="utf-8"';
    XmlPart.ContentTransfer := '7bit';
    XmlPart.ContentID := '<soap_part>';

    // Second message part contains the attachments
    AttachmentPart := TIdText.Create(Msg.MessageParts, nil);
    AttachmentPart.ContentType := 'multipart/related';
    AttachmentPart.Boundary := 'MMS_PART';

    // Add attachments to the attachment part
    for i := 0 to Attachments.Count - 1 do
        AttachmentDesc := Attachments[i] as TMM7Attachment; //
Description of attachment
TIdAttachmentFile.Create(Msg.MessageParts,AttachmentDesc.FileName) do
          ParentPart := AttachmentPart.Index; // Set parent part in the
          ContentType := AttachmentDesc.ContentType; // Set content
mime type
          ContentID := 'attachment_' + IntToStr(i); // Unique ID for
each attachment

          // if auto, determine MIME type from extension
          if ContentType = 'auto' then
            ContentType :=

So at the end XmlPart has it's Content-ID okay, but AttachmentPart has
nothing, only it's Conent-Type header.

Generated message looks like this:

Content-Type: text/xml; charset="utf-8"
Content-Transfer-Encoding: 7bit
Content-ID: <soap_part>

XML COMES HERE (removed to be shorter)

Content-Type: multipart/related;

Content-Type: text/plain;
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
Content-ID: attachment_0


Content-Type: image/jpeg;
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
Content-ID: attachment_1

JPEG DATA IS HERE (removed to be shorter)



Thanks for your help,
        Vandra Ákos