Hi Casartelli,
According to your description, you want to make sure whether the PDF file in attachment has existed in folder before saving the attachment PDF file.
I wrote a sample added to your codes below.
Public Sub saveAttachtoDisk(itm As Outlook.MailItem)
Dim objAtt As Outlook.Attachment
Dim saveFolder As String
Dim DirFile As String
saveFolder = "S:\NL\"
For Each objAtt In itm.Attachments
If (Right(objAtt.Filename, 3) = "pdf") Then
DirFile = saveFolder & "\" & objAtt.DisplayName
If Dir(DirFile) = "" Then 'the file not exists
objAtt.SaveAsFile DirFile
Else
DirFile = saveFolder & "\" & Replace(objAtt.Filename, ".pdf", "") & Format(Now, "yyyyMMddhhmmss") & ".pdf"
objAtt.SaveAsFile DirFile
End If
Set objAtt = Nothing
End If
Next
End Sub
<THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
Thanks
MSDN Community Support
Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.