VBScript Requires Chilkat v11.0.0+
VBScript
Forward an email as an attachment
See more Email Object Examples
Attach the original Email to a new message as a message/rfc822 part. The recipient can open the attached email and read its original headers and body.
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 original = CreateObject("Chilkat.Email")
success = original.LoadEml("message.eml")
If (success <> 1) Then
outFile.WriteLine(original.LastErrorText)
WScript.Quit
End If
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 = "Forwarded message"
email.Body = "The original email is attached."
success = email.AttachEmail(original)
If (success <> 1) Then
outFile.WriteLine(email.LastErrorText)
WScript.Quit
End If
success = email.SaveEml("forward-as-attachment.eml")
If (success <> 1) Then
outFile.WriteLine(email.LastErrorText)
WScript.Quit
End If
outFile.WriteLine("Saved forward-as-attachment.eml.")
outFile.Close