earthworm
Well-known Member
- Joined
- May 19, 2009
- Messages
- 759
- Office Version
- 2019
- 2016
- Platform
- Windows
I have found the below macro from net and made some changes .
This macro is adding specific file only . I need to add any type of file extension in outlook as an attachment from a specific folder path . Please help
please note that on later stage i will make the folder variable to pick any file from variable folder and once the email is sent, The files in that folder deletes . So that on next day i dont have to clear my folders up to run
This macro is adding specific file only . I need to add any type of file extension in outlook as an attachment from a specific folder path . Please help
please note that on later stage i will make the folder variable to pick any file from variable folder and once the email is sent, The files in that folder deletes . So that on next day i dont have to clear my folders up to run
VBA Code:
Sub Email_From_Excel_More_Options()
' Email
Dim emailApplication As Object
Dim emailItem As Object
Set emailApplication = CreateObject("Outlook.Application")
Set emailItem = emailApplication.CreateItem(0)
If Range("B1").Value > 0 Then
' To add more receipt use structure emailItem.to = "email1@test.com; email2@test.com; email3@test.com"
' emailItem.to = Range("C1").Value & "; " & Range("D1").Value & "; " & Range("E1").Value
emailItem.To = Range("C1").Value & "; " & Range("D1").Value & "; " & Range("E1").Value
emailItem.CC = "email1@test.com"
' emailItem.BCC = "email3@test.com"
emailItem.Subject = "Subject line for the email."
emailItem.Body = "The message for the email."
' Attach any file from your computer.
emailItem.Attachments.Add ("C:\Users\iiiii\OneDrive\Desktop\Test\1.txt")
' Send the Email
' emailItem.Send
' Display the Email so the user can change it as desired before sending it.
' Use this OR .Send, but not both together.
emailItem.Display
Set emailItem = Nothing
Set emailApplication = Nothing
Else
End If