• 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...

  • 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

Veeru106

Member
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
 
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
 
Code:
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]
 
Back
Top