Email is essential, but repetitive tasks—like addressing replies by name and adding appropriate greetings—can be tedious. Especially if your like me and send scores and scores of emails each day. Introducing GreetHammer, a handy Outlook macro compatible with Outlook 2016, 2019, and Office 365 that fully automates personalized email greetings, saving you valuable time.

What is GreetHammer?

GreetHammer is a simple yet powerful macro for Microsoft Outlook designed to streamline the process of replying to emails by automatically inserting personalized greetings based on the recipient’s first name and the time of day. It eliminates the manual task of typing greetings, letting you jump straight to the core of your message.

Why Use GreetHammer?

How Does GreetHammer Work?

Here's a quick breakdown:

Automated Name Detection

GreetHammer intelligently extracts the recipient’s first name from the sender's details.

Dynamic Greeting Based on Time

Automatically adjusts greetings based on the time of day:

Professional Email Formatting

Inserts greetings formatted neatly using Calibri Light font, colored consistently to match Outlook's standard reply style.

Reply All Functionality

GreetHammer uses the "Reply All" function to address all original email recipients.

Implementing GreetHammer

Step 1: Setting Up the Macro

Step 2: Adjust Security Settings

Step 3: Create a Ribbon Button

Step 4: Run the Macro

Your reply email will automatically open with a personalized greeting ready.

Customizing GreetHammer

You can further adjust the script based on your preferences:

Benefits of Using GreetHammer


GreetHammer helps you handle your Outlook communications faster, more efficiently, and with professional polish. Automate your email greetings and reclaim your valuable time with this simple yet powerful tool!

Happy emailing!

Sub AutoReplyAllWithGreeting()
    Dim originalMail As MailItem
    Dim replyMail As MailItem
    Dim recipientName As String
    Dim currentHour As Integer
    Dim greeting As String
    Dim indent As String
    Dim replyColor As String
    
    ' Define the color code for standard Outlook reply blue
    replyColor = "#1F497D"
    
    ' Check if an email is selected
    If Application.ActiveExplorer.Selection.Count = 0 Then
        MsgBox "Please select an email to reply to."
        Exit Sub
    End If
    
    ' Get the selected email
    Set originalMail = Application.ActiveExplorer.Selection.Item(1)
    
    ' Create the "Reply All"
    Set replyMail = originalMail.ReplyAll
    
    ' Simply extract the sender's first name for the greeting
    recipientName = GetFirstName(originalMail.SenderName)
    
    ' Get the current hour
    currentHour = Hour(Now)
    
    ' Determine the greeting based on the time of day
    Select Case currentHour
        Case 0 To 11
            greeting = "Good morning."
        Case 12 To 16
            greeting = "Good afternoon."
        Case Else
            greeting = "Good evening."
    End Select
    
    ' Set indentation, using HTML for proper email formatting
    indent = "     " ' 5 non-breaking spaces for indentation in HTML
    
    ' Insert the personalized greeting into the reply with color styling and Calibri Light font
    replyMail.HTMLBody = _
        "<p style='color:" & replyColor & "; font-family: Calibri Light; font-size: 11pt;'>" & _
            recipientName & "," & _
        "</p>" & _
        "<p style='color:" & replyColor & "; font-family: Calibri Light; font-size: 11pt;'>" & _
            indent & greeting & _
        "</p>" & _
        replyMail.HTMLBody
    
    ' Display the reply email
    replyMail.Display
End Sub

' Function to extract the first name from the full name
Function GetFirstName(fullName As String) As String
    Dim nameParts() As String
    
    ' Check if the name is formatted with a comma (e.g., "LastName, FirstName")
    If InStr(fullName, ",") > 0 Then
        ' Split by comma and trim any extra spaces
        nameParts = Split(fullName, ",")
        GetFirstName = Trim(nameParts(1)) ' Use the second part, which is the first name
    Else
        ' Otherwise, split by space and return the first part (assumed to be first name)
        nameParts = Split(fullName, " ")
        GetFirstName = nameParts(0)
    End If
End Function