KlausW
Active Member
- Joined
- Sep 9, 2020
- Messages
- 458
- Office Version
- 2016
- Platform
- Windows
Hello
I use this VBA code to send mail with an attachment and it works as it should.
Someone who can help so that it sends all the files in a folder.
The name of the folder is in cell x18.
Anyone who can help?
Any help will be appreciated.
Best Regards
Klaus W
I use this VBA code to send mail with an attachment and it works as it should.
Someone who can help so that it sends all the files in a folder.
The name of the folder is in cell x18.
Anyone who can help?
Any help will be appreciated.
Best Regards
Klaus W
VBA Code:
Sub maj_Rektangelafrundedehjørner1_Klik()
'Skal bruges
Dim MyOutlook As Object
Set MyOutlook = CreateObject("Outlook.Application")
Dim MyMail As Object
Set MyMail = MyOutlook.CreateItem(olMailItem)
MyMail.To = Range("x2").Value ' & "; " & Range("y3").Value & "; " & Range("y4").Value & "; " & Range("y5").Value & "; " & Range("ay6").Value
MyMail.Subject = Range("x9").Value
MyMail.Body = Range("x10").Value & vbNewLine & vbNewLine & Range("x11").Value & vbNewLine & _
Range("x12").Value & vbNewLine & Range("x13").Value & vbNewLine & Range("x14").Value & vbNewLine & _
Range("x15").Value
Attached_File = Range("x18").Value
MyMail.Attachments.Add Attached_File
MyMail.Send
'MoveAFile
End Sub