I am not sure how it worked correctly when you had
sDirectory = "C:\Temp_PDF_Print"
'rather than
sDirectory = "C:\Temp_PDF_Print\"
'and
sFile = ATTACHMENT_DIRECTORY & oAtt.FileName
The simplest approach to this is to use the script (slightly modified and in a normal module rather than ThisOutlookSession) to run from a rule that checks all incoming mail to admin(at)someemail(dot)com as it arrives in the inbox. If the Scripts option is missing from the rules, then see https://www.slipstick.com/outlook/ru...-script-rules/
I would suggest creating the temporary file on the desktop then delete it after printing.
The modified code also works on 64 bit Office.
Option Explicit
#If VBA7 Then
Private Declare PtrSafe Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" ( _
ByVal hwnd As LongPtr, ByVal lpOperation As String, ByVal lpFile As String, _
ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As LongPtr) As LongPtr
#Else
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" ( _
ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, _
ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
#End If
Public Sub PrintAttachments(oMail As Outlook.MailItem)
On Error Resume Next
Dim colAtts As Outlook.Attachments
Dim oAtt As Outlook.Attachment
Dim sFile As String
Dim sDirectory As String
Dim sFileType As String
If TypeName(oMail) = "MailItem" Then
sDirectory = Environ("USERPROFILE") & "\Desktop\"
Set colAtts = oMail.Attachments
If colAtts.Count Then
For Each oAtt In colAtts
sFileType = LCase$(Right$(oAtt.FileName, 4))
Select Case sFileType
Case ".pdf"
sFile = sDirectory & oAtt.FileName
oAtt.SaveAsFile sFile
ShellExecute 0, "print", sFile, vbNullString, vbNullString, 0
End Select
Next
End If
End If
Set colAtts = Nothing
Set oAtt = Nothing
Set oMail = Nothing
End Sub