Results 1 to 7 of 7

Thread: Insert salutation

  1. #1
    Member
    Join Date
    Aug 2011
    Posts
    54
    Rep Power
    13

    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
    Attached Files Attached Files
    Last edited by DocAElstein; 10-02-2023 at 12:57 PM.

  2. #2
    Senior Member alansidman's Avatar
    Join Date
    Apr 2012
    Posts
    125
    Rep Power
    13
    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 & _

  3. #3
    Member
    Join Date
    Aug 2011
    Posts
    54
    Rep Power
    13
    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

  4. #4
    Senior Member alansidman's Avatar
    Join Date
    Apr 2012
    Posts
    125
    Rep Power
    13
    You may want to use chr(13) instead.

    Read this link and try the different variations:

    Force carriage return in string - Access World Forums

  5. #5
    Member
    Join Date
    Aug 2011
    Posts
    54
    Rep Power
    13
    Hi Alansidman,

    I am sorry, i tried but could not bring the text to the new line.

  6. #6
    Moderator
    Join Date
    Jul 2012
    Posts
    156
    Rep Power
    12
    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>"

  7. #7
    Member
    Join Date
    Aug 2011
    Posts
    54
    Rep Power
    13
    Thank you so much!!

Similar Threads

  1. Choose A Salutation Based On Time Using VBA
    By Prabhu in forum Excel Help
    Replies: 4
    Last Post: 10-26-2013, 11:18 AM
  2. Insert Value When A Conditin is Met
    By Ajit in forum Excel Help
    Replies: 3
    Last Post: 09-12-2013, 06:58 PM
  3. Automatically Insert Row
    By marreco in forum Excel Help
    Replies: 7
    Last Post: 12-21-2012, 06:43 PM
  4. Insert Picture in a Cell UDF
    By Admin in forum Download Center
    Replies: 10
    Last Post: 12-07-2012, 04:49 PM
  5. help with after insert event in Access 10
    By richlyn in forum Access Help
    Replies: 9
    Last Post: 03-03-2012, 10:49 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •