1. Welcome to Chandoo.org Forums. Short message for you

    Hi Guest,

    Thanks for joining Chandoo.org forums. We are here to make you awesome in Excel. Before you post your first question, please read this short introduction guide. When posting or responding to questions please remember our values at Chandoo.org are: Humility, Passion, Fun, Awesomeness, Simplicity, Sharing Remember that we have people here for whom English is not there first language and we need to allow for this in our dealings.

    Yours,
    Chandoo
  2. Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  3. When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

code for outlook mail with body

Discussion in 'VBA Macros' started by Veeru106, Jun 19, 2017 at 5:30 PM.

  1. Veeru106

    Veeru106 Member

    Messages:
    48
    HI,


    I was trying to send outlook mail via code and want some more body message in my mail.


    Below code is working fine except it is not picking up body message.


    Please suggest changes to be made.


    Thanks
  2. Veeru106

    Veeru106 Member

    Messages:
    48
    Sub attachment()
    Dim strlocation As String
    Dim outapp As Object
    Dim outmail As Object
    Dim strbody As String
    Set outapp = CreateObject("outlook.application")
    Set outmail = outapp.createitem(0)
    strlocation = "C:\Users\varun.vashisht\Desktop\New folder\Raw Sheet.xlsm"
    strbody = "Hi there" & vbNewLine & vbNewLine & _
    "Thanks for visiting" & vbNewLine & _
    "For your kind" & vbNewLine & _
    "Will meet you" & vbNewLine & _
    "Thanks & Regards"
    With outmail
    .To = ""
    .CC = ""
    .BCC = ""
    .Subject = "Training Structure"
    .Attachments.Add (strlocation)
    .display
    End With
    Set outmail = Nothing
    Set outapp = Nothing
    With Application
    .ScreenUpdating = True
    .EnableEvents = True
    End With
    End Sub
  3. Logit

    Logit Member

    Messages:
    67
    Code (vb):

    Option Explicit

    Sub attachment()
    Dim strlocation As String
    Dim outapp As Object
    Dim outmail As Object
    Dim strbody As String
    Set outapp = CreateObject("outlook.application")
    Set outmail = outapp.createitem(0)
    strlocation = "C:\Users\varun.vashisht\Desktop\New folder\Raw Sheet.xlsm"
    strbody = "Hi there" & vbNewLine & vbNewLine & _
    "Thanks for visiting" & vbNewLine & _
    "For your kind" & vbNewLine & _
    "Will meet you" & vbNewLine & _
    "Thanks & Regards"
    With outmail
    .To = ""
    .CC = ""
    .BCC = ""
    .Subject = "Training Structure"
    .Body = strbody                             '<<<---------<<<<<<<<<<<<
    .Attachments.Add (strlocation)
    .display
    End With
    Set outmail = Nothing
    Set outapp = Nothing
    With Application
    .ScreenUpdating = True
    .EnableEvents = True
    End With
    End Sub
    [\Code]
  4. Veeru106

    Veeru106 Member

    Messages:
    48
    It is working...Thanks
  5. Logit

    Logit Member

    Messages:
    67
    You are welcome.

Share This Page