Archived Forum Post

Index of archived forum posts

Question:

Image in Email Handled as Attachment and not Related Data?

Dec 21 '16 at 15:32

I have an email message that contains an embedded image.

The image in the email has a Content-ID and this content ID is referred in the body's html so this should come under the "related data" category, Chilkat handles it as an "attachment".

Why is this the case?


Answer

A "related item" is an image or other MIME sub-part that is contained within the multipart/related enclosure. I've had a look at the .eml you sent to me in private email, and it has the following MIME structure:

multipart/mixed
    multipart/alternative
        text/plain
        text/html
    image/png

The image is contained in the multipart/mixed enclosure (which is the typical place where attachments are located), and there is no multipart/related enclosure.

For example, a typical email that contains a multipart/related image referenced from HTML, and also has an attachment, would look like this:

multipart/mixed
    multipart/alternative
        text/plain
        multipart/related
            text/html
            image/jpeg
    application/pdf

PS> It's not feasible for Chilkat to be trying to parse the HTML body to determine if a particular image is "related" or not. The decision is based on the location of the image within the MIME structure.


Answer

Here's another example of an email with incorrect structure, where the HTML images are not properly placed inside a multipart/related enclosure, and are instead located where attachments should be..

multipart/mixed
    multipart/alternative
        text/plain
        text/html
    application/postscript
    application/pdf
    application/postscript
    application/x-zip-compressed
    application/octet-stream
    image/jpeg
    image/jpeg
    image/png
    image/jpeg
    image/png