VBScript Requires Chilkat v11.0.0+
VBScript
Read the plain-text and HTML bodies separately
See more Email Object Examples
When both alternatives exist, Body returns HTML. Use the explicit body accessors to choose text for an index or HTML for a viewer. This example reads alternatives.eml from the previous example.
Chilkat VBScript Downloads
Dim fso, outFile
Set fso = CreateObject("Scripting.FileSystemObject")
'Create a Unicode (utf-16) output text file.
Set outFile = fso.CreateTextFile("output.txt", True, True)
success = 0
' Assumes Chilkat is unlocked. See Global Unlock Sample.
set email = CreateObject("Chilkat.Email")
success = email.LoadEml("alternatives.eml")
If (success <> 1) Then
outFile.WriteLine(email.LastErrorText)
WScript.Quit
End If
' A message can have either representation, both, or neither.
If (email.HasPlainTextBody() = 1) Then
outFile.WriteLine("Plain text: " & email.GetPlainTextBody())
End If
If (email.HasHtmlBody() = 1) Then
outFile.WriteLine("HTML source: " & email.GetHtmlBody())
End If
If ((email.HasPlainTextBody() = 0) And (email.HasHtmlBody() = 0)) Then
outFile.WriteLine("No text or HTML body. Inspect the MIME parts.")
End If
outFile.Close