Hello all,
I'm looking for a vba code which will attach all files in a specific folder except for one ending with .xlsm.
The code which is Bold is the code which attaches all files in that specific folder to the email.
I've got this code now:
Sub Mail()
Dim OutApp As Object
Dim OutMail As Object
Dim strbody As String
Dim StrFile As String
Dim StrPath As String
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
StrPath = Range("L55") & ""
strbody = "Text"
On Error Resume Next
With OutMail
.Display
.To = Range("L57")
.CC = "test@test.nl"
.BCC = ""
.Subject = Range("N4")
.HTMLBody = strbody & .HTMLBody
StrFile = Dir(StrPath & "*.*")
Do While Len(StrFile) > 0
.Attachments.Add StrPath & StrFile
StrFile = Dir
Loop
End With
On Error GoTo 0
Set OutMail = Nothing
Set OutApp = Nothing
End Sub
I'm looking for a vba code which will attach all files in a specific folder except for one ending with .xlsm.
The code which is Bold is the code which attaches all files in that specific folder to the email.
I've got this code now:
Sub Mail()
Dim OutApp As Object
Dim OutMail As Object
Dim strbody As String
Dim StrFile As String
Dim StrPath As String
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
StrPath = Range("L55") & ""
strbody = "Text"
On Error Resume Next
With OutMail
.Display
.To = Range("L57")
.CC = "test@test.nl"
.BCC = ""
.Subject = Range("N4")
.HTMLBody = strbody & .HTMLBody
StrFile = Dir(StrPath & "*.*")
Do While Len(StrFile) > 0
.Attachments.Add StrPath & StrFile
StrFile = Dir
Loop
End With
On Error GoTo 0
Set OutMail = Nothing
Set OutApp = Nothing
End Sub