Need help with VBA to skip attaching file if file is not found in the folder i have tried adding the "if then" but no luck there. would someone please be able to help here I want the vba to skip if file is not found and attach other files that are found only.
With objEmail
.To =
.Cc =
.Subject =
'.HTMLBody = RangetoHTML(rng)
.HTMLBody = StrBody2 & "<br>" & RangetoHTML(rng) & "<br>" & StrBody3 & "<br>" & .HTMLBody
pdfFileName1 = Dir(pdfFolderPath1 & "file.pdf")
pdfFileName5 = Dir(pdfFolderPath4 & "file2.pdf")
pdfFileName6 = Dir(pdfFolderPath4 & "file3.pdf")
pdfFileName2 = Dir(pdfFolderPath2 & "file4.pdf")
pdfFileName3 = Dir(pdfFolderPath3 & "file5.pdf")
pdfFileName4 = Dir(pdfFolderPath3 & "file6.pdf")
pdfFilePath1 = pdfFolderPath1 & pdfFileName1
pdfFilePath2 = pdfFolderPath2 & pdfFileName2
pdfFilePath3 = pdfFolderPath3 & pdfFileName3
pdfFilePath4 = pdfFolderPath3 & pdfFileName4
pdfFilePath5 = pdfFolderPath4 & pdfFileName5
pdfFilePath5 = pdfFolderPath4 & pdfFileName6
.Attachments.Add pdfFilePath1, , , pdfFileName1
.Attachments.Add pdfFilePath2, , , pdfFileName2
pdfFileName = Dir
.Attachments.Add pdfFilePath3, , , pdfFileName3
.Attachments.Add pdfFilePath4, , , pdfFileName4
.Attachments.Add pdfFilePath5, , , pdfFileName5
.Attachments.Add pdfFilePath5, , , pdfFileName6
.Display ' DISPLAY MESSAGE.
End With
With Application
End Sub