Sample code for 30+ languages & platforms
AutoIt 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 AutoIt Downloads

AutoIt
Local $bSuccess = False

;  Assumes Chilkat is unlocked. See Global Unlock Sample.

$oEmail = ObjCreate("Chilkat.Email")
$bSuccess = $oEmail.LoadEml("with-attachments.eml")
If ($bSuccess <> True) Then
    ConsoleWrite($oEmail.LastErrorText & @CRLF)
    Exit
EndIf

$oPreview = ObjCreate("Chilkat.Email")
$bSuccess = $oEmail.MakeCopy($oPreview)
If ($bSuccess <> True) Then
    ConsoleWrite($oEmail.LastErrorText & @CRLF)
    Exit
EndIf

;  Keep related items: the HTML still refers to them.
$oPreview.DropAttachments 
ConsoleWrite("Files in original: " & $oEmail.NumAttachments & "  Files in preview: " & $oPreview.NumAttachments & @CRLF)
If ($oPreview.HasHtmlBody() <> True) Then
    ConsoleWrite("This message has no HTML preview." & @CRLF)
    Exit
EndIf

$oHtml = ObjCreate("Chilkat.StringBuilder")
$bSuccess = $oPreview.GetHtmlBodySb(True,$oHtml)
If ($bSuccess <> True) Then
    ConsoleWrite($oPreview.LastErrorText & @CRLF)
    Exit
EndIf

$bSuccess = $oHtml.WriteFile("preview.html","utf-8",False)
If ($bSuccess <> True) Then
    ConsoleWrite("Failed: html.WriteFile." & @CRLF)
    Exit
EndIf

ConsoleWrite("Saved preview.html." & @CRLF)