VBANEWBIE1229
New Member
- Joined
- Oct 19, 2017
- Messages
- 5
Hi guys, I am trying to send an email automatically from excel 2013 using VBA, the email is successful, however, I am having trouble getting it to attach a document from a referenced cell. I would like it to attach the document that is linked into cell B9. The following code is what I have. Thanks in advance for your help!!!
Rich (BB code):
Private Sub CommandButton21_Click()
Dim OutApp As Object
Dim OutMail As Object
Set OutApp = CreateObject("Outlook.Application")
OutApp.Session.Logon
Set OutMail = OutApp.CreateItem(0)
Set Rng = Range("B9")
On Error Resume Next
With OutMail
.To = Range("D9")
.CC = Range("E9")
.BCC = ""
.Subject = "Subject"
.Body = "Body"
.Attachments.Add ActiveSheet.Range("b9").Select
.Display
End With
On Error GoTo 0
Set OutMail = Nothing
Set OutApp = Nothing
End Sub
Last edited by a moderator: