Very new to Powershell, and I have been unable to find how to use 'Print to PDF' for a png file and save it in the same location as a pdf.
I found the code below, and the first portion works great to save an email attachment to the specified folder.
$ol = New-Object -Com Outlook.Application $ns = $ol.GetNameSpace('MAPI') $olinbox = 6 $inbox = $ns.GetDefaultFolder( $olInbox ) $olPdfFolder = $inbox.Folders.Item('testsubfolder') $olPdfFolder.Items | %{ foreach ($attachment in $_.Attachments) { $attachment.SaveAsFile( "C:test$($attachment.FileName)") } } $shell = New-Object -com Shell.Application $shell.Namespace('C:test').Items() | %{ $_.InvokeVerb('Print') }
The code that is not working is the following, and I am unable to find how to convert the saved png file to a pdf.
$shell = New-Object -com Shell.Application $shell.Namespace('C:test').Items() | %{ $_.InvokeVerb('Print') }
Ultimately I am trying to save a png email attachment, convert it to a pdf, then attach to a new email and send. I would also like to schedule this task. I know there is a better solution!