VBScript Requires Chilkat v11.0.0+
VBScript
Create, save, and reopen a plain-text email
See more Email Object Examples
Set the sender, recipient, subject, and plain-text body. Save the result as an EML file, then open it in a second Email object and read its contents.
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 = "Sam Lee <sam@example.com>"
success = email.AddTo("Alex Rivera","alex@example.net")
If (success <> 1) Then
outFile.WriteLine(email.LastErrorText)
WScript.Quit
End If
email.Subject = "Hello"
email.Body = "This is a plain-text message."
success = email.SaveEml("message.eml")
If (success <> 1) Then
outFile.WriteLine(email.LastErrorText)
WScript.Quit
End If
set received = CreateObject("Chilkat.Email")
success = received.LoadEml("message.eml")
If (success <> 1) Then
outFile.WriteLine(received.LastErrorText)
WScript.Quit
End If
outFile.WriteLine(received.From)
outFile.WriteLine(received.Subject)
outFile.WriteLine(received.GetPlainTextBody())
outFile.Close