Archived Forum Post

Index of archived forum posts

Question:

Get Related Items from EML file

Nov 05 '12 at 12:24

Hello, i am using Chilkat.Email2 (registered ) to LoadEml file, ok no problem in display the html/text body parts but if there are related items like images i can't display them on the html reading page, or if i display the related items the text/html body never is displayed . The related items are embedded as CID in the HTML body Can anyone help me please

I am using ASP classic, on windows 2008r2 server

Thank You


Answer

In HTML email, the images referenced from within the HTML (i.e. referenced from the SRC attribute of IMG tags), are contained within the MIME of the email itself. Within the MIME, the images are located under the "multipart/related" sub-part, and this is why Chilkat refers to them as "related items". If the URL in the SRC attribute uses a "CID" reference, then the image data is found within the MIME via the Content-ID header field. If the SRC attribute is a URL, which may be a full URL beginning with "http:/", or a path relative to the HTML file itself, then the image data within the MIME is found via the "Content-Location" header.

When HTML is extracted from the MIME and rendered by a browser, it is no longer within the context of the original MIME. The browser knows nothing about the MIME, nor does it have access to it. The browser is not capable of rendering "CID" references. If a reference is a URL (non-CID), then the browser will try to fetch the URL as it normally would.

The only solution I've found is to extract the HTML and related items to temporary files, and at the same time modify the SRC attribute of IMG tags of the HTML to point to the temporary image files. This is exactly what the emailObject.UnpackHtml method does.


Answer

Than you, But there is a problem with UnpackHtml that i don't know how to solve. If the sender uses outlook, hotmail, yahoo or gmail the unpackhtml works 110% but if the sender uses MAIL 5.3 (1283) from OSX and if it only attach images there is no problem the problem start when the sender attach for example a PDF i cant find why but unpakhtml assumes the TEXT body as HTML body and simply forget the html body format.

If you like i can send you an EML or an email from OSX Mail , the only thing i can figure is that when the email as PDF or other Attached the OSX Mail send the email as multipart/alternative and Outlook and others send as multipart/mixed. Is there a way to solve that " unstandard ", and i just find another problem, in MAIL, if the attached file is an image and if it as portuguese characters in the file name it loses the image, unpak saves it but ... not display it because of the name

Thank You


Answer

If you suspect a problem with UnpackHtml for certain emails, then do this:

1) Make sure you test with the very latest version of Chilkat. You first want to make sure it's not a problem that was already fixed.

2) If the problem remains in the latest version, send the .eml to support@chilkatsoft.com in a zipped attachment.


Answer

Ok i will, thank you


Answer

The problem is that PDF's are not "related items". The PDF is a true email attachment. It is located under the "multipart/mixed" sub-tree, and it is not actually referenced from within the HTML. Many email clients will render attachments marked as "inline" via the Content-Disposition header following. That's what you see when viewing the email in Outlook or Thunderbird. However, the browser has no knowledge of the PDF, and it's not referenced from with the HTML. To save the PDF, you would call the methods for saving "attachments", not "related items".

PS> This is the actual HTML within your test email. You can see that it does not reference the PDF:

<html><head></head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">
asdsadsa<div>dsad</div>
<div>sa</div>
<div>d</div>
<div><b>sad</b></div>
<div><b>sa</b></div>
<div>d</div>
<div>sad</div>
<div><br></div>
<div><br></div>
<div></div>
</body></html>


Answer

ok but take a look when is a pdf + image attached it gets only the textbody and not the htmlbody try it please i sent you 2 eml files