This handy bit of Powerscript code allows you to save attachements in your Outlook inbox to disk:
You need to pass a file name, not just a destination directory to SaveAsFile.The attachment has a FileName property.
This code groups attachments with same name and saves the first attachment in each group, if the attachment is corrupt or if it can't... This handy bit of Powerscript code allows you to save attachements in your Outlook inbox to disk:
You need to pass a file name, not just a destination directory to SaveAsFile.The attachment has a FileName property.
This code groups attachments with same name and saves the first attachment in each group, if the attachment is corrupt or if it can't save it the Trap handles the exception; in this sample it just writes a message.You could also iterate through each group's attachments and append a different number to the name in order to save all.
$inbox=6
$outlook = new-object -com Outlook.Application
$inbox = $outlook.Session.GetDefaultFolder($inbox)
foreach ($group in $inbox.items % {$_.attachments} group filename) {
trap {
Write-Host There was a problem saving $fName
continue}
if ($group.Name.startswith("SECTSPDR")) {
$fName = "C:\TEMP\$($group.Name)"
$group.Group[0].saveasfile($fName)
if ($?) {Write-Host $fName was saved succesfuly.}
}
}

Read more http://billennis-ssts.blogspot.com/2009/07/save-outlook-attachements-to-disk.html