PowerShell Requires Chilkat v11.0.0+
PowerShell
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 PowerShell Downloads
Add-Type -Path "C:\chilkat\ChilkatDotNet47-x64\ChilkatDotNet47.dll"
$success = $false
# Assumes Chilkat is unlocked. See Global Unlock Sample.
$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 = "Hello"
$email.Body = "This is a plain-text message."
$success = $email.SaveEml("message.eml")
if ($success -ne $true) {
$($email.LastErrorText)
exit
}
$received = New-Object Chilkat.Email
$success = $received.LoadEml("message.eml")
if ($success -ne $true) {
$($received.LastErrorText)
exit
}
$($received.From)
$($received.Subject)
$($received.GetPlainTextBody())