- Larry
You may have a problem automating the printing of the attachments, but you
can definitely save them all to a common directory. I'm not sure if you can
select multiple documents of different formats and easily right-click to
print them all.
Are the attachments all the same format/document type?
Marco
"Larry__Weiss" <l...@airmail.net> wrote in message
news:#Cc7mh03...@TK2MSFTNGP02.phx.gbl...
The attached file format will be PDF. The email client is Outlook.
I want to use this as a real-world example of the use of PowerShell to
demonstrate at the NTPCUG PowerShell SIG.
- Larry
Reinhard
"Larry__Weiss" wrote:
> .
>
- Larry
This example assumes you have a subfolder 'Pdf' under your inbox folder
where the e-mails with the pdf-attachments reside and you have a folder
C:\pdf in your filesystem.
Outlookversion: 2002 (hope other/higher versions support this code too)
$ol = New-Object -Com Outlook.Application
$ns = $ol.GetNameSpace('MAPI')
$olinbox = 6
$inbox = $ns.GetDefaultFolder( $olInbox )
$olPdfFolder = $inbox.Folders.Item('pdf')
$olPdfFolder.Items | %{
foreach ($attachment in $_.Attachments)
{
$attachment.SaveAsFile( "C:\pdf\$($attachment.FileName)")
}
}
$shell = New -com Shell.Application
$shell.Namespace('C:\pdf').Items() | %{ $_.InvokeVerb('Print') }
hope this meets your needs and you get success.
Reinhard
PS: you can also transfer the code above in just 2 lines. the first one does
the outlook job, the second one does the shell job. pretty cool what we can
do with psh.
"Larry__Weiss" wrote:
> .
>
- Larry
Very interesting approach! My suggestions would have been to use COM with
Microsoft Word to print the PDFs, but that would likely be more resource
intensive.
Marco
"Larry__Weiss" wrote:
> .
>
We used it as an example to demonstrate PowerShell usage at
the North Texas PC Users Group PowerShell SIG in Dallas
this morning. The only thing we had to change was
the next to last line where we modified it to be
$shell = New-Object -com Shell.Application
- Larry
On 4/21/2010 2:56 AM, rkd wrote:
> Hi Larry, please try this once:
>
> This example assumes you have a subfolder 'Pdf' under your inbox folder
> where the e-mails with the pdf-attachments reside and you have a folder
> C:\pdf in your filesystem.
> Outlookversion: 2002 (hope other/higher versions support this code too)
>
> $ol = New-Object -Com Outlook.Application
> $ns = $ol.GetNameSpace('MAPI')
> $olinbox = 6
> $inbox = $ns.GetDefaultFolder( $olInbox )
> $olPdfFolder = $inbox.Folders.Item('pdf')
> $olPdfFolder.Items | %{
> foreach ($attachment in $_.Attachments)
> {
> $attachment.SaveAsFile( "C:\pdf\$($attachment.FileName)")
> }
> }
>
> $shell = New -com Shell.Application
> $shell.Namespace('C:\pdf').Items() | %{ $_.InvokeVerb('Print') }
>
> hope this meets your needs and you get success.
> Reinhard
>
> PS: you can also transfer the code above in just 2 lines. the first one does
> the outlook job, the second one does the shell job. pretty cool what we can
> do with psh.
>
> "Larry__Weiss" wrote:
>> It is the pop based client.
>>
>>
Is there a good book out there that explains the Outlook object model?
And if there is a revision of a book that shows PowerShell examples of
using the Outlook object model that would be ideal.
- Larry