Reputation: 11
I want to automatically send emails through Outlook. It gets as far as myAttachments.Add
and states:
Object doesn't support this property or method.
I've tried this a few different ways, but errors continue on the attachment section. All other sections work creating the email.
What am I doing wrong?
Sub Send_Emails()
Dim OutlookApp As Outlook.Application
Dim OutlookMail As Outlook.MailItem
Dim myAttachments As Outlook.Attachments
Set OutlookApp = New Outlook.Application
Set OutlookMail = OutlookApp.CreateItem(olMailItem)
Set myAttachments = OutlookMail.Attachments
myAttachments.Add Source:=ThisWorkbook, Type:=olByValue
With OutlookMail
.BodyFormat = olFormatHTML
.HTMLBody = "Attached is the Transaction Report"
.To = "[email protected]"
.Subject = "Transaction Report"
.Send
End With
End Sub
Upvotes: 1
Views: 148
Reputation: 9199
With OutlookMail
.To = "[email protected]"
.Attachments.Add ThisWorkbook.fullName
.Display
End With
Upvotes: 1