I have a script i scraped from other scripts. It works except i am quite new to powershell and am a sys admin not a dev, (but reading my ass off). I can get the scrtipt to work downloading attachments from inbox in outlook but need it to download attachments from a subfolder instead:
############################# Outlook Call ##############################
$olFolderInbox = 6
$outlook = new-object -com outlook.application;
$ns = $outlook.GetNameSpace("MAPI");
$inbox = $ns.GetDefaultFolder($olFolderInbox)
$messages = $inbox.items
write-host $messages.count
$messcount = $messages.count
foreach($message in $messages){
##############Save Attachments################
$filepath = "c:\attachments\"
$message.attachments|foreach {
Write-Host $_.filename
$attr = $_.filename
$_.saveasfile((Join-Path $filepath $_.filename))
$a = $_.filename
If ($a.Contains("")) {
$_.saveasfile((Join-Path $filepath $a))
}
}
}
###########END##########
Any Ideas anyone? Would be massively grateful.