PDA

View Full Version : [SOLVED] help wanted.



alfredmentin
02-27-2015, 08:29 AM
Hello everyone :hi:

I need some help with the script below, it's working great but i would like to add a additional function to it.

I work with this script within outlook (rules).

When i receive a email from a certain supplier (invoices) it's now been saved to a certain folder, so far so good!
However i also would like that the script automatically prints the attachment (.pdf) that comes with the email.

I am not known with vba scripts....

Can somebody help me with this??

Thanks in advance

Alfred


Public Sub saveAttachtoDisk(itm As Outlook.MailItem)
Dim objAtt As Outlook.Attachment
Dim saveFolder As String
saveFolder = "C:\data\Docs"
For Each objAtt In itm.Attachments
If InStr(objAtt.DisplayName, ".pdf") Then
objAtt.SaveAsFile saveFolder & "\" & objAtt.DisplayName
End If
Set objAtt = Nothing
Next
End Sub

alfredmentin
02-28-2015, 06:48 AM
I found the solution myself:

Now the scrips works just fine.


Public Sub saveAttachtoDisk(itm As Outlook.MailItem)
Dim objAtt As Outlook.Attachment
Dim saveFolder As String
saveFolder = "H:\minox\Data\A0021115\Docs"
For Each objAtt In itm.Attachments
If InStr(objAtt.DisplayName, ".pdf") Then
objAtt.SaveAsFile saveFolder & "\" & objAtt.DisplayName
Shell """C:\Program Files\Adobe\Reader 11.0\Reader\acrord32.exe"" /h /p """ + saveFolder & "\" & objAtt.DisplayName + """", vbHide
End If
Set objAtt = Nothing
Next
End Sub