Sample code for 30+ languages & platforms
Classic ASP Requires Chilkat v11.0.0+

Create an HTML preview with embedded images

See more Email Object Examples

Make an independent copy of with-attachments.eml, remove ordinary file attachments from the copy, and export its HTML with related images as data URLs. The original retains its attachments. Use a sanitized viewer when showing untrusted HTML.

Chilkat Classic ASP Downloads

Classic ASP
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<%
success = 0

'  Assumes Chilkat is unlocked. See Global Unlock Sample.

set email = Server.CreateObject("Chilkat.Email")
success = email.LoadEml("with-attachments.eml")
If (success <> 1) Then
    Response.Write "<pre>" & Server.HTMLEncode( email.LastErrorText) & "</pre>"
    Response.End
End If

set preview = Server.CreateObject("Chilkat.Email")
success = email.MakeCopy(preview)
If (success <> 1) Then
    Response.Write "<pre>" & Server.HTMLEncode( email.LastErrorText) & "</pre>"
    Response.End
End If

'  Keep related items: the HTML still refers to them.
preview.DropAttachments 
Response.Write "<pre>" & Server.HTMLEncode( "Files in original: " & email.NumAttachments & "  Files in preview: " & preview.NumAttachments) & "</pre>"
If (preview.HasHtmlBody() <> 1) Then
    Response.Write "<pre>" & Server.HTMLEncode( "This message has no HTML preview.") & "</pre>"
    Response.End
End If

set html = Server.CreateObject("Chilkat.StringBuilder")
success = preview.GetHtmlBodySb(1,html)
If (success <> 1) Then
    Response.Write "<pre>" & Server.HTMLEncode( preview.LastErrorText) & "</pre>"
    Response.End
End If

success = html.WriteFile("preview.html","utf-8",0)
If (success <> 1) Then
    Response.Write "<pre>" & Server.HTMLEncode( "Failed: html.WriteFile.") & "</pre>"
    Response.End
End If

Response.Write "<pre>" & Server.HTMLEncode( "Saved preview.html.") & "</pre>"

%>
</body>
</html>