Required to add attachment to .Send
Driving me NUTS :banghead::banghead::banghead::banghead::banghead::banghead:
In the simple little macro below, if I do NOT include an attachment, I get an error 287 on .Send
With an attached file, the message is generated and sent as expected
Is there any way that I would not have to .Add an attachment
Win7 64bit, MS Office 2010
Thanks
Code:
Option Explicit
Sub SendEmail()
Dim OutApp As Object
Dim OutMail As Object
Dim sFile As String, sBody As String, sRecipiant
sBody = "This is an email message"
sFile = "C:\Users\Me\Scripts\Logs\bu2000-2015-01-20.log"
sRecipiant = "me@here.net"
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
With OutMail
.To = sRecipiant
.CC = vbNullString
.BCC = vbNullString
.Subject = "email test -- " & Format(Now, "General Date")
.Body = sBody
'without attachment I get an error 287 on the .Send
.Attachments.Add sFile
.ReadReceiptRequested = False
'err 287 - application-defined or object-defined error
.Send
End With
Set OutMail = Nothing
Set OutApp = Nothing
End Sub