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?
- Efficiency: Quickly reply with personalized greetings without manual effort.
- Professionalism: Consistently formatted and polite responses enhance your professional image.
- Ease of Use: A single click to generate fully personalized email replies.
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:
- “Good morning” for emails before noon.
- “Good afternoon” from noon to 4 PM.
- “Good evening” after 4 PM.
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
- Open Outlook.
- Press
ALT + F11
to open the VBA editor. - In the Project pane, navigate to
Project1 (VbaProject.OTM)
. - Right-click on “Modules”, select “Insert”, then “Module”.
- Paste the provided GreetHammer code into the new module.
Step 2: Adjust Security Settings
- Ensure macros are enabled in Outlook:
- Go to
File > Options > Trust Center > Trust Center Settings > Macro Settings
- Select
Notifications for digitally signed macros, all other macros disabled
, orEnable all macros
if your policy allows.
- Go to
Step 3: Create a Ribbon Button
- Right-click on the Outlook ribbon and select
Customize the Ribbon
. - In the right pane, create a new group in your desired tab by clicking
New Group
. - Rename the group (e.g., “GreetHammer”).
- From the “Choose commands from” dropdown, select “Macros”.
- Find and select your macro (e.g., “AutoReplyAllWithGreeting”) and click “Add >>”.
- Rename the macro button for clarity (e.g., “GreetHammer”) by clicking the “Rename” button.
- Choose an icon, then click OK.
- Your macro is now easily accessible from the Outlook ribbon!
Step 4: Run the Macro
- Select an email in your Inbox.
- Click the newly created ribbon button or press
ALT + F8
, selectAutoReplyAllWithGreeting
, then click “Run”.
Your reply email will automatically open with a personalized greeting ready.
Customizing GreetHammer
You can further adjust the script based on your preferences:
-
Reply Colors and Fonts: Modify the
replyColor
or font settings within the macro to match your preferences. (I chose the shade of blue that represents replies) -
Greeting Times: Adjust the hours in the “Determine the greeting based on the time of day” section for your working hours.
Benefits of Using GreetHammer
- Personalized Communication: Addresses each recipient by name automatically.
- Time-Saving: Eliminates redundant typing, speeding up email workflows.
- Consistency: Ensures professional greetings and formatting in every email.
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