|Subject:||TIdMessage Content-ID not showing|
|Date:||Sun, 20 Jul 2008|
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.
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
ParentPart := AttachmentPart.Index; // Set parent part in the
ContentType := AttachmentDesc.ContentType; // Set content
ContentID := 'attachment_' + IntToStr(i); // Unique ID for
// if auto, determine MIME type from extension
if ContentType = 'auto' then
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"
XML COMES HERE (removed to be shorter)
JPEG DATA IS HERE (removed to be shorter)
Thanks for your help,