Share via

String body in email

Anonymous
2018-04-19T15:35:36+00:00

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

Microsoft 365 and Office | Excel | For home | Windows

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.

0 comments No comments

Answer accepted by question author

Anonymous
2018-04-19T15:45:41+00:00

Hi,

strBody does not exist, use .Body instead.

Was this answer helpful?

2 people found this answer helpful.
0 comments No comments

3 additional answers

Sort by: Most helpful
  1. Deleted

    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

  2. Anonymous
    2018-04-20T10:16:37+00:00

    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

    Was this answer helpful?

    0 comments No comments
  3. Anonymous
    2018-04-19T15:48:42+00:00

    Well, I had started using the .Body, but couldn't get it to work for some reason. Now it is working. 

    Thank you

    Was this answer helpful?

    0 comments No comments