These are chat archives for IndySockets/Indy
TIdText *t = new TIdText(pMessage->MessageParts, NULL); t->ContentType = "text/plain"; t->Body->Text = "Test"; TIdText *h = new TIdText(pMessage->MessageParts, NULL); h->ContentType = "text/html"; h->Body->Text = "Test"; TIdText *a = new TIdText(pMessage->MessageParts, NULL); a->ContentType = "multipart/alternative"; a->ParentPart = -1; t->ParentPart = a->Index; h->ParentPart = a->Index;
text/plaincontent no message part is needed. If HTML is added, the
text/plainis converted and both parts are appended to the
alternativepart. Same with
relatedif a graphic is added earlier or later.
ParentPartto the previous "multipart/alternative" part. In short,
ParentPartshould always refer to an earlier part, never to a later part. If you want to convert an email from one layout to another, you basically need to start fresh with a new message and make sure you add parts to it in the correct order, copying data from old parts to new parts as needed. This will be much easier once IndySockets/Indy#139 is implemented, as you will be able to just move parts around from one collection to another. But for now, you have to do thing manually to make it work correctly. I suppose a possible workaround would be to update
TIdMessageto scan the
MessagePartsfor items with
ParentPart=-1, then rescan for
=1, etc. But that is a lot more work, especially for how it currently tracks and pops used MIME boundaries. Easier to just make sure the parts in the right order to begin with
TIdMessageBuilderHtmlwhich is working fine.
whileloop runs out of MIME boundaries to send, indicating a malformed email. Raising an exception while sending an email would cause communication issues for NNTP and SMTP at least, so I would have to update them to close the socket if
TIdMessagefails to encode. That would be a minor change, thoguh