A family of Microsoft spreadsheet software with tools for analyzing, charting, and communicating data.
Hi,
strBody does not exist, use .Body instead.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
I have a code that I am trying to write in an Excel spreadsheet that sends an email with an attachment, but I can't get the body to work. This is what I have written so far.
Sub Mail_workbook_Outlook_1()
Dim OutApp As Object
Dim OutMail As Object
Dim strbody As String
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
On Error Resume Next
With OutMail
.to = "Testing"
.CC = ""
.BCC = ""
.Subject = "ETO Scorecard" & " " & Format(Date, "mm/dd/yy")
.strbody = "Hello Everyone," & vbNewLine & vbNewLine & _
"Please find the new ETO Data Scorecard attached and also in BOX link below:" & vbNewLine & vbNewLine & _
"https://schneider-electric.box.com/s/w0hfid8o3z3jur59se4c47qhphmadwci" & vbNewLine & vbNewLine & _
"Remember…" & vbNewLine & vbNewLine & _
"ETO database available on server: wvusstl471" & vbNewLine & vbNewLine & _
"D:\Objects\ETO - PLEASE COPY" & vbNewLine & vbNewLine & _
"Kind Regards!"
.Attachments.Add ("C:\Users\SESA27956\Desktop\ETO Scoreboard.xlsx")
.Display
End With
On Error GoTo 0
Set OutMail = Nothing
Set OutApp = Nothing
End Sub
A family of Microsoft spreadsheet software with tools for analyzing, charting, and communicating data.
Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.
Answer accepted by question author
Hi,
strBody does not exist, use .Body instead.
This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.
Comments have been turned off. Learn more
Hi darrend7,
We are glad to know that your issue has been resolved. Meanwhile, very thanks for JP Ronse’s sharing.
Have a nice day.
Regards,
Anna
Well, I had started using the .Body, but couldn't get it to work for some reason. Now it is working.
Thank you