Bob Fishel
Bob Fishel

Reputation: 123

Reading MSG file from outlook via powershell .. how to get email address?

Fairly simple script at the moment I simply need to get the recipients email address out of a msg file, apparently there's not an easy way to parse it in text so I've used the following code, but I only get a name such as 'Joe Smith' when reading the message not [email protected]

Any ideas?

Thanks!

$outlook = New-Object -comobject outlook.application
$msg = $outlook.CreateItemFromTemplate("c:\MyMessage.msg")
$msg | Select to

Upvotes: 0

Views: 2646

Answers (1)

Dmitry Streblechenko
Dmitry Streblechenko

Reputation: 66225

You need to access the Recipients collection and read the Recipient.Address property for the items in that collection. You also might want to use Application.Session.OpenSharedItem instead of CreateItemFromTemplate.

Upvotes: 1

Related Questions