-
1 Attachment(s)
Insert salutation
Hi Friends,
I have attached macro which will help me to send work sheet thru outlook mail.
In this macro i am using "HI" in front of Persons Name.
can we use Good morning,Good afternoon or good Evening word based on timing instead of "Hi"
if we can kindly help with the VBA coding.
Many thanks in advance
Regards,
Prabhu
https://www.youtube.com/channel/UCnxwq2aGJRbjOo_MO54oaHA
-
Here is some code that you can use to test time of day. Insert as I have here:
Code:
Dim StrBody As String
Dim LTime As String
If Time > 0 And Time < #11:59:59 AM# Then
LTime = "Good Morning"
ElseIf Time > #12:00:00 PM# And Time < #6:00:00 PM# Then
LTime = "Good Afternoon"
ElseIf Time > #6:00:00 PM# And Time < #11:59:59 PM# Then
LTime = "Good Evening"
End If
StrBody = LTime & " Mr.abcd... ," & vbCrLf & _
vbCrLf & _
"Pls find the Attached Outstanding Report as on" & " " & FormatDateTime(Date, vbLongDate) & "." & vbCrLf & _
vbCrLf & _
-
Thank you so much!
It is working good.
i have a one more small correction.
Even after inserting the code "vbCrLf" all are printing in the first line i.e. Name and the message (Pls find the Attached ...)
can we move the message to next line? if so kindly help.
Regards,
Prabhu
-
You may want to use chr(13) instead.
Read this link and try the different variations:
Force carriage return in string - Access World Forums
-
Hi Alansidman,
I am sorry, i tried but could not bring the text to the new line.
-
Try
Code:
.htmlbody = "<HTML><BODY><p> " & LTime & " Mr.abcd... ," & " <br /> </p>" & _
"<p>Pls find the Attached Outstanding Report as on " & FormatDateTime(Date, vbLongDate) & "." & " <br /> <br /> </p>" & _
"<p> ======================================================================================== </p>"
-