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

Inspect the MIME structure and contents of an EML file

See more Email Object Examples

Open the complete EML in Mime for a tree view and in Email for application-level collections. An HTML logo, downloadable file, attached message, and delivery report are counted separately. Try the complex workshop draft.

Chilkat PowerShell Downloads

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

$success = $false

#  Assumes Chilkat is unlocked. See Global Unlock Sample.

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

$mime = New-Object Chilkat.Mime
$success = $mime.LoadMimeFile("workshop.eml")
if ($success -ne $true) {
    $($mime.LastErrorText)
    exit
}

$($mime.GetStructure("text"))
$("Subject: " + $email.Subject)
$("Files: " + $email.NumAttachments + "  Related items: " + $email.NumRelatedItems)
$("Attached messages: " + $email.NumAttachedMessages + "  Reports: " + $email.NumReports)
$i = 0
while (($i -lt $email.NumAttachments)) {
    $($email.GetAttachmentFilename($i) + "  " + $email.GetAttachmentContentType($i) + "  " + $email.GetAttachmentSize($i) + " bytes")
    $i = $i + 1
}

$i = 0
while (($i -lt $email.NumRelatedItems)) {
    $("Related: " + $email.GetRelatedFilename($i) + "  " + $email.GetRelatedContentType($i))
    $i = $i + 1
}