VBScript Requires Chilkat v11.0.0+
VBScript
Choose the character set for an HTML email
See more Email Object Examples
Read a UTF-8 HTML file as Unicode, then set the charset Chilkat will use when writing the MIME text. The HTML file’s input encoding and the message’s output charset are separate choices. UTF-8 can represent names from multiple writing systems.
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")
email.From = "Workshop team <events@example.com>"
success = email.AddTo("Alex Rivera","alex@example.net")
If (success <> 1) Then
outFile.WriteLine(email.LastErrorText)
WScript.Quit
End If
email.Subject = "Workshop registration"
set html = CreateObject("Chilkat.StringBuilder")
success = html.LoadFile("newsletter.html","utf-8")
If (success <> 1) Then
outFile.WriteLine("Failed: html.LoadFile.")
WScript.Quit
End If
email.Charset = "utf-8"
email.SetHtmlBody html.GetAsString()
success = email.SaveEml("newsletter.eml")
If (success <> 1) Then
outFile.WriteLine(email.LastErrorText)
WScript.Quit
End If
outFile.WriteLine("Saved newsletter.eml.")
outFile.Close