'.Send property on VBA not working. .Display and other properties work just fine
I am stumped. I am working from my personal computer, so there are no security measures that are preventing me from using the macro. Also, I have checked all of the properties boxes on VB project. The issue is when I use .Send on my code it does not work. However, .Display works just fine. In fact when I type .send it wont even capitalize it. Almost as if the property does not exist. I am using the latest version of Excel. Here is my code:
Sub SendEmailAttachment()
Dim outlookApp As Object
Dim outMail As Object
Dim myAttachments As Object
Dim emailAddress As String
Dim emailAddressCC As String
Dim emailSubject As String
Dim fileName As String
Dim filePath As String
Dim attachment As String
Dim attachment2 As String
Dim signature As String
Dim lastrow As Integer
Dim x As Integer
x = 2
Do While Sheet1.Cells(x, 1) <> ""
Set outlookApp = CreateObject("Outlook.Application")
Set outMail = outlookApp.CreateItem(0)
Set myAttachments = outMail.Attachments
filePath = ThisWorkbook.Path & "\"
emailAddress = Sheet1.Cells(x, 3)
emailAddressCC = Sheet1.Cells(x, 13)
emailSubject = Sheet1.Cells(x, 17)
fileName = Sheet1.Cells(x, 16)
attachment = filePath + fileName
attachment2 = filePath + "CEO Letter to Employees.Pdf"
With outMail
.send 'issue here
End With
signature = outMail.HTMLbody
With outMail
.To = emailAddress
.cc = emailAddressCC
.bcc = ""
.Subject = emailSubject
.HTMLbody = "Please find your statement attached" & vbCrLf & "Best Regards" & signature
myAttachments.Add (attachment2)
myAttachments.Add (attachment)
.send 'issue here
lastrow = lastrow + 1
emailAddress = ""
x = x + 1
Set outlookApp = Nothing
Set outMail = Nothing
End With
Loop
End Sub
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
