Xojo Plugin Requires Chilkat v11.0.0+
Xojo Plugin
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 Xojo Plugin Downloads
Dim success As Boolean
success = False
// Assumes Chilkat is unlocked. See Global Unlock Sample.
Dim email As New Chilkat.Email
success = email.LoadEml("with-attachments.eml")
If (success <> True) Then
System.DebugLog(email.LastErrorText)
Return
End If
Dim preview As New Chilkat.Email
success = email.MakeCopy(preview)
If (success <> True) Then
System.DebugLog(email.LastErrorText)
Return
End If
// Keep related items: the HTML still refers to them.
preview.DropAttachments
System.DebugLog("Files in original: " + Str(email.NumAttachments) + " Files in preview: " + Str(preview.NumAttachments))
If (preview.HasHtmlBody() <> True) Then
System.DebugLog("This message has no HTML preview.")
Return
End If
Dim html As New Chilkat.StringBuilder
success = preview.GetHtmlBodySb(True,html)
If (success <> True) Then
System.DebugLog(preview.LastErrorText)
Return
End If
success = html.WriteFile("preview.html","utf-8",False)
If (success <> True) Then
System.DebugLog("Failed: html.WriteFile.")
Return
End If
System.DebugLog("Saved preview.html.")