jakpsalmon
New Member
- Joined
- May 26, 2017
- Messages
- 1
Hi guys,
I'm after a VBA that will allow my outlook to look into a folder and pick up a latest file attach to an email and send to an email address.
I have been playing around with the following but get an error on the '.file' section.
Sub AttachMultiple()
Dim folder As String, file As String
folder = "K:\scheduler\reports"
With CreateObject("Outlook.Application").CreateItem(0)
.To = "Chris.bourgaize@specsavers.com"
.Subject = "Test"
.file = Split(CreateObject("wscript.shell").exec("cmd /c Dir /b /o-d """ & folder & """.xlsx").stdout.readall, vbCrLf)(0)
.Attachment.Add folder & file
.Send
End With
End Sub
Anyone able to help??
Many thanks,
Jake
I'm after a VBA that will allow my outlook to look into a folder and pick up a latest file attach to an email and send to an email address.
I have been playing around with the following but get an error on the '.file' section.
Sub AttachMultiple()
Dim folder As String, file As String
folder = "K:\scheduler\reports"
With CreateObject("Outlook.Application").CreateItem(0)
.To = "Chris.bourgaize@specsavers.com"
.Subject = "Test"
.file = Split(CreateObject("wscript.shell").exec("cmd /c Dir /b /o-d """ & folder & """.xlsx").stdout.readall, vbCrLf)(0)
.Attachment.Add folder & file
.Send
End With
End Sub
Anyone able to help??
Many thanks,
Jake