We have a macro that sends e-mails of documents in a certain directory. We want to exclude documents whose file names begin with "AUT_XXXXXX" ETA: the Xs can be a string of letters and numbers that vary.
Below is the macro we currently use:
Sub SendScannedDocstoWellsFargo()
Dim Filename As Variant
Dim olApp As Outlook.Application
Dim olNewEmail As Outlook.MailItem
Dim strDirectory As String
Dim strPath As String
Dim FSO As FileSystemObject
Set FSO = CreateObject("Scripting.FileSystemObject")
Set olApp = Outlook.Application
Filename = Dir("\kwa-file01ClientFilesWells Fargo III\_Scanned_DocumentsPending Uploads")
strDirectory = "\kwa-file01ClientFilesWells Fargo III\_Scanned_DocumentsPending Uploads"
While Filename <> ""
'Comment out when completed
'Debug.Print Filename
'Set the filename to the next file
Filename = Dir
'Create a path for the item
strPath = strDirectory & Filename
If strPath = strDirectory Then GoTo StopThisNow
'Create a mail item
Set olNewEmail = olApp.CreateItem(olMailItem)
With olNewEmail
.To = "[email protected]"
.Subject = Filename
.Attachments.Add (strPath)
.Send
End With
FSO.DeleteFile strPath, True
Set olNewEmail = Nothing
StopThisNow:
Wend
Set olApp = Nothing
Set olNewEmail = Nothing
strDirectory = ""
Filename = ""
strPath = ""
End Sub
I've seen other posts showing how to exclude certain file types, but these files are all PDFs.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…