sending of attachments with email using VBA in Microsoft Excel
Hello, I am trying to automate the sending of attachments with email using VBA in Microsoft Excel.
I have it working except for the attachment piece, does anyone know how to set it up so I can attach for example "C:\Temp\Text.txt"? I've attached the code that works without the attachment piece below.
Dim objOL As New Outlook.Application
Dim objMail As MailItem
Set objOL = New Outlook.Application
Set objMail = objOL.CreateItem(olMailItem)
.To = "email@example.com"
.CC = ""
.Subject = "test email"
.Body = "test line 1" & Chr(10) & Chr(10) _
& "test line 2" & Chr(10) & Chr(10)
.Attachments = ("c:\temp\text.txt")
Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.