Sample code for 30+ languages & platforms
PowerShell Requires Chilkat v11.0.0+

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 PowerShell Downloads

PowerShell
Add-Type -Path "C:\chilkat\ChilkatDotNet47-x64\ChilkatDotNet47.dll"

$success = $false

#  Assumes Chilkat is unlocked. See Global Unlock Sample.

$original = New-Object Chilkat.Email
$success = $original.LoadEml("message.eml")
if ($success -ne $true) {
    $($original.LastErrorText)
    exit
}

$email = New-Object Chilkat.Email
$email.From = "Sam Lee <sam@example.com>"
$success = $email.AddTo("Alex Rivera","alex@example.net")
if ($success -ne $true) {
    $($email.LastErrorText)
    exit
}

$email.Subject = "Forwarded message"
$email.Body = "The original email is attached."
$success = $email.AttachEmail($original)
if ($success -ne $true) {
    $($email.LastErrorText)
    exit
}

$success = $email.SaveEml("forward-as-attachment.eml")
if ($success -ne $true) {
    $($email.LastErrorText)
    exit
}

$("Saved forward-as-attachment.eml.")