I am trying to figure a way of printing attachments that land in a subfolder of outlook. I have got as far as a script which extracts them to a folder, but i am wondering if i should power shell print from that folder, or if there is just a way of printing them as they get sent to that folder first.
#file path
$filepath = “c:\tests\”
#set outlook to open
$o = New-Object -comobject outlook.application
$n = $o.GetNamespace(“MAPI”)
#you'll get a popup in outlook at this point where you pick the folder you want to scan
#$f = $n.pickfolder()
$Account = $n.Folders | ? { $_.Name -eq '[email protected]' };
$Inbox = $Account.Folders | ? { $_.Name -match 'Inbox' };
$f = $Inbox.Folders | ? { $_.Name -match 'colour' };
#now loop through them and grab the attachments
$f.Items | foreach {
$_.attachments | foreach {
Write-Host $_.filename
$a = $_.filename
$_.saveasfile((Join-Path $filepath $a)) | Foreach-Object { Start-Process -FilePath $_.FullName –Verb Print }
}
}
this extracts the attachments but doesnt print.
This does print that folder:
Dir c:\tests\*.* | Foreach-Object { Start-Process -FilePath $_.FullName –Verb Print }
I have these two scripts but am unsure how i would either print each attachment from script 1 or combine script 1 and 2, can anyone help?
Thanks in advance