Quantcast
Channel: PowerShell
Viewing all articles
Browse latest Browse all 15370

Powershell save email attachment and delete

$
0
0
Powershell
Need a little help here. I an working on a script that goes through a mailbox and saves the attachment based on the subject. I have that piece working just fine but when I add the lines to set the email to read and move it to the deleted it only processes 2 of the emails. Below is what I have so far. The lines causing the issue are:

$_.UnRead = $false

$_.Move($deleted) | out-null

Whole Script:
Powershell
$o=New-Object-ComObjectOutlook.Application$n=$o.GetNamespace("MAPI")$inbox=$n.GetDefaultFolder(6)$deleted=$n.GetDefaultFolder(3)$filepathPick="I:\remote_stores\pick_tickets_appleton"$filepathPack="I:\remote_stores\packing_slips_appleton"$inbox.Items|foreach{If($_.subject-match"pi"){$_.attachments|foreach{$_.saveasfile((Join-Path$filepathPick$_.filename))}$_.UnRead=$false$_.Move($deleted)|out-null}...

Viewing all articles
Browse latest Browse all 15370

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>