# encoding: ascii
# api: powershell
# title: Get-MailAttachment.ps1
# description: Get an attachment from an exchange e-mail.
# version: 0.1
# author: George Mauer
# license: CC0
# x-poshcode-id: 2578
# x-archived: 2017-03-01T06:58:02
# x-published: 2012-03-24T14:42:00
#
# Use with – http://poshcode.org/2520 
# Requires the installation of Exchange Web Services API:
# Docs: http://msdn.microsoft.com/en-us/library/dd637749(v=exchg.80).aspx
# Download: http://www.microsoft.com/downloads/en/details.aspx?FamilyID=c3342fb3-fbcc-4127-becf-872c746840e1
#
param([Microsoft.Exchange.WebServices.Data.FileAttachment]$attachment)
"Downloading Attachment"
$attachment.Load()
"Done"
$path = "C:\temp\"+$attachment.Name
"Writing to $path"
set-content -value $mm[1].Attachments[0].Content -enc byte -path $path
"Done"
ii $path
