View Single Post
 
Old 04-19-2018, 01:33 AM
fabien fabien is offline Windows 10 Office 2016
Novice
 
Join Date: Apr 2018
Posts: 2
fabien is on a distinguished road
Default Outlook - Reply with greetings: "Hi (first name),"

Good afternoon everyone,

I am coming to you as I am trying to write a code that adds simple greetings when replying to an email: "Hi (sender's first name),"

I managed to get this code going and it works well, however my issue is the formatting, which I thought would have been an easy fix, however all my attempts failed...

My code below:

Code:
Sub AutoAddGreetingtoReplyAll()

    Dim oMail As MailItem
    Dim oReply As MailItem
    Dim GreetTime As String

  Select Case Application.ActiveWindow.Class
           Case olInspector
                Set oMail = ActiveInspector.currentItem
           Case olExplorer
                Set oMail = ActiveExplorer.Selection.Item(1)

    End Select

    Set oReply = oMail.Reply

With oReply

         .HTMLBody = "Hi " & Split(oMail.SenderName)(0) & "," & .HTMLBody
         .Display

    End With

End Sub
I have tried to replace the .HTMLBody line with the following, however while the "Hi" and "," get formatted with the correct font (font size comes up to 10pt...), my main issue is with & Split(oMail.SenderName)(0) &, that does not get formatted at all.

Code:
.HTMLBody = "<span style='font-size:11.0pt;font-family:""Century Gothic"" '>Hi </span>" & Split(oMail.SenderName)(0) & "<span style='font-size:11.0pt;font-family:""Century Gothic"" '>,</span>" & .HTMLBody
Appreciate your help.

Cheers,
Fabien
Reply With Quote