VBScript
VBScript
Save HTML Email Embedded Images
Saves HTML embedded items to files in a subdirectory. Images, style sheets, and anything else embedded within HTML, are not considered to be attachments. Instead, these items are "related item". The Chilkat email object provides a set of methods/properties for accessing the related items within an email.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
set email = CreateObject("Chilkat.Email")
' Load an email object containing HTML with embedded images.
success = email.LoadEml("myEmails/HtmlEmail.eml")
If (success <> 1) Then
outFile.WriteLine(email.LastErrorText)
WScript.Quit
End If
' Iterate over the related items.
' Print the file name and save each to a file.
i = 0
numRelated = email.NumRelatedItems
Do While i < numRelated
outFile.WriteLine(email.GetRelatedFilename(i))
success = email.SaveRelatedItem(i,"myRelatedItemsDir")
If (success <> 1) Then
outFile.WriteLine(email.LastErrorText)
WScript.Quit
End If
i = i + 1
Loop
outFile.Close