Moving Emails to subfolder with Powershell -


i trying write sender/subject info of emails in outlook inbox csv file , move emails subfolder of inbox (called "after") using powershell. csv file created correctly email info, first half + 1 emails moved subfolder. here code:

$olfolderinbox = 6; $outlook = new-object -com outlook.application; $mapi = $outlook.getnamespace("mapi"); $inbox = $mapi.getdefaultfolder($olfolderinbox); $inbox.items|select senderemailaddress,subject|export-csv c:\scripts\testing.csv -notypeinformation; foreach ($item in $inbox.items){     try{         $item.move($inbox.folders.item("after")) | out-null;     }catch{         write-host "failed move item", $item.id.uniqueid;     } } 

this first time using powershell appreciated!

move() changes collection. use down "for" loop (from items.count down 1) instead of "foreach".


Comments

Popular posts from this blog

python - TypeError: start must be a integer -

c# - DevExpress RepositoryItemComboBox BackColor property ignored -

django - Creating multiple model instances in DRF3 -