sending of attachments with email using VBA in Microsoft Excel
Posted on 2007-03-28
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")
Set objMail = Nothing
Set objOL = Nothing