(PowerShell) Access Attached Message (Embedded Email)
How to access an email embedded within another email (i.e. an attached message). Note: This example requires Chilkat v11.0.0 or greater.
Add-Type -Path "C:\chilkat\ChilkatDotNet47-x64\ChilkatDotNet47.dll"
$success = $false
$email = New-Object Chilkat.Email
# Load an email from a .eml
$success = $email.LoadEml("embeddedEmail.eml")
if ($success -eq $false) {
$($email.LastErrorText)
exit
}
# Display how many attached emails are embedded within
# this one:
$numAttached = $email.NumAttachedMessages
$("numAttached = " + $numAttached)
# Get the 1st attached message.
$email2 = New-Object Chilkat.Email
$success = $email.GetAttachedEmail(0,$email2)
if ($success -eq $true) {
# Display the subject, From, and a header field...
$($email2.Subject)
$($email2.From)
$($email2.GetHeaderField("X-SOMETHING"))
}
|