I frequent a few forums... Did you (or someone else) already ask this
question a few months ago?
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" <lfw@airmail.net> wrote in message
news:#Cc7mh03KHA.3352@TK2MSFTNGP02.phx.gbl...
> I need help writing a PowerShell script to automate printing
> the attachments to email in Outlook.
>
> - Larry
I'm assisting a friend of mine with the creation of this script,
and I have discovered some previous threads, but nothing that ties
the whole thing together.
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
On 4/19/2010 7:42 AM, Marco Shaw [MVP] wrote:
> I frequent a few forums... Did you (or someone else) already ask this
> question a few months ago?
>
> 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" <lfw@airmail.net> wrote in message
> news:#Cc7mh03KHA.3352@TK2MSFTNGP02.phx.gbl...
>> I need help writing a PowerShell script to automate printing
>> the attachments to email in Outlook.
>>
>> - Larry
>
Are you a bit familiar with the outlook object model? using it could bring
the solution. Let me know. I could try to create a code snippet. Do you use
Outlook as an Exchange-Client oder pop/imap-client?
Reinhard
"Larry__Weiss" wrote:
> I need help writing a PowerShell script to automate printing
> the attachments to email in Outlook.
>
> - Larry
> .
>
It is the pop based client.
- Larry
On 4/20/2010 6:33 AM, rkd wrote:
> Are you a bit familiar with the outlook object model? using it could bring
> the solution. Let me know. I could try to create a code snippet. Do you use
> Outlook as an Exchange-Client oder pop/imap-client?
>
> Reinhard
>
> "Larry__Weiss" wrote:
>
>> I need help writing a PowerShell script to automate printing
>> the attachments to email in Outlook.
>>
>> - Larry
>> .
>>
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.
>
> - Larry
>
> On 4/20/2010 6:33 AM, rkd wrote:
> > Are you a bit familiar with the outlook object model? using it could bring
> > the solution. Let me know. I could try to create a code snippet. Do you use
> > Outlook as an Exchange-Client oder pop/imap-client?
> >
> > Reinhard
> >
> > "Larry__Weiss" wrote:
> >
> >> I need help writing a PowerShell script to automate printing
> >> the attachments to email in Outlook.
> >>
> >> - Larry
> >> .
> >>
> .
>
Thanks! I'll test it and give you some feedback.
Do you have a reference for the Outlook object model that you can recommend?
- 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.
>>
>> - Larry
>>
>> On 4/20/2010 6:33 AM, rkd wrote:
>>> Are you a bit familiar with the outlook object model? using it could bring
>>> the solution. Let me know. I could try to create a code snippet. Do you use
>>> Outlook as an Exchange-Client oder pop/imap-client?
>>>
>>> Reinhard
>>>
>>> "Larry__Weiss" wrote:
>>>
>>>> I need help writing a PowerShell script to automate printing
>>>> the attachments to email in Outlook.
>>>>
>>>> - Larry
>>>> .
>>>>
>> .
>>
> $shell = New -com Shell.Application
> $shell.Namespace('C:\pdf').Items() | %{ $_.InvokeVerb('Print') }
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
I used the online help of my outlook installation, topic 'forms and
programming informations'.
But it can be that the programming part of the online help is part of an
optional installation topic, so a standard installation doesn't provide such
a help topic
Reinhard
"Larry__Weiss" wrote:
> Thanks! I'll test it and give you some feedback.
> Do you have a reference for the Outlook object model that you can recommend?
>
> - 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.
> >>
> >> - Larry
> >>
> >> On 4/20/2010 6:33 AM, rkd wrote:
> >>> Are you a bit familiar with the outlook object model? using it could bring
> >>> the solution. Let me know. I could try to create a code snippet. Do you use
> >>> Outlook as an Exchange-Client oder pop/imap-client?
> >>>
> >>> Reinhard
> >>>
> >>> "Larry__Weiss" wrote:
> >>>
> >>>> I need help writing a PowerShell script to automate printing
> >>>> the attachments to email in Outlook.
> >>>>
> >>>> - Larry
> >>>> .
> >>>>
> >> .
> >>
> .
>
Yes you're very right, Marco. the shell.application Com-object offers a few
very interessting things. I neglected it for a long time. Only in the last
time i took my focus more on it and it seems that it payed out :-)
Reinhard
"Marco Shaw [MVP]" wrote:
> > $shell = New -com Shell.Application
> > $shell.Namespace('C:\pdf').Items() | %{ $_.InvokeVerb('Print') }
>
> 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
>
Thanks again for the PowerShell code.
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.
>>
>>
>> On 4/20/2010 6:33 AM, rkd wrote:
>>> Are you a bit familiar with the outlook object model? using it could bring
>>> the solution. Let me know. I could try to create a code snippet. Do you use
>>> Outlook as an Exchange-Client oder pop/imap-client?
>>>
>>> Reinhard
>>>
>>> "Larry__Weiss" wrote:
>>>> I need help writing a PowerShell script to automate printing
>>>> the attachments to email in Outlook.
>>>>
Now that I have a start on this script, I'd like to add more smarts to
it (like moving the emails to another folder after saving the
attachments so the next time I execute it, it won't re-print any
previous attachments).
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
On 5/15/2010 5:36 PM, Larry__Weiss wrote:
> Thanks again for the PowerShell code.
>
> 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.
>>>
>>>
>>> On 4/20/2010 6:33 AM, rkd wrote:
>>>> Are you a bit familiar with the outlook object model? using it could
>>>> bring
>>>> the solution. Let me know. I could try to create a code snippet. Do
>>>> you use
>>>> Outlook as an Exchange-Client oder pop/imap-client?
>>>>
>>>> Reinhard
>>>>
>>>> "Larry__Weiss" wrote:
>>>>> I need help writing a PowerShell script to automate printing
>>>>> the attachments to email in Outlook.
>>>>>
microsoft.public.outlook.program_vba Email parser & extractor for Outlook Dhan 0 397 eMail-Lead Grabber Business is an email extractor ... to save incoming mail in TRUE csv format Utf 1 328 I have a script in Outlook ...
microsoft.public.windows.powershell - page 6 ... Hi, I am trying to set the Print Area in a ... to piece them together I have a list of email ... Larry__Weiss 7 441 Theoretically, can a PowerShell script do ...
How do I Save Outlook Attachments using Powershell? How do I Save Outlook Attachments using Powershell? ... but none for powershell. Here is a script I found to open Outlook and pick ... so the first email it comes ...
JBs Powershell: A cmdlet-like email script # PowerShell 1.0 script to send email through SMTP ... # alert icon will be used in outlook). ... com/2008/10/powershell-email-locks-attachment.html
How to Send an Email With Powershell | eHow.com How to Send an Email With Powershell. PowerShell is a powerful shell and script ... cmdlet can include attachments ... Delete Contacts in PowerShell; How to Delete Outlook Email ...
How to send an email using a Windows Powershell script Google Query: send email with powershell ... because the script and the attachment has to ... set a reminder in Outlook using this script? I’m trying to send an smtp html email ...