user2642759
user2642759

Reputation: 33

Parse body of msg (email) file

I need to parse the body of emails to get the contents of a table out of each email. I would like to use PowerShell to do this. I have tried this code:

Get-ChildItem "C:\Users\mmartindale.NTSERVER\Desktop\delreg temp\msg" -Filter *.msg |
    ForEach-Object {
        $outlook = New-Object -comobject outlook.application
        $msg = $outlook.Session.OpenSharedItem($_.FullName)
        $msg | Select body | ft -AutoSize
    }

But all I get is an abbreviated output like this:

Body
----
This is approved for Deal Reg...

How do I output this as an object that I can loop through?

Upvotes: 3

Views: 9655

Answers (1)

sodawillow
sodawillow

Reputation: 13176

You can use Select-Object's -ExpandProperty parameter to expand the property you want.

As in:

$msg | Select-Object -ExpandProperty Body

Upvotes: 2

Related Questions