The ultimate in lazy emailing?
September 6, 2008 – 4:25 pm by JP
Lately I've been getting tired of writing a greeting line in every message I send (50-60 per day).
I know that writing someone's name (or a greeting line like "Hello") seems trivial, but it adds up when you send as many emails as I do. It just gets annoying and tiring, especially if you don't mean it
Yes, that is how I get a lot of my ideas; just doing something over and over and thinking, "there's got to be a better way." So I adjusted the code found here to insert a greeting line at the top of every email.
I wrote two versions; one for "Reply" and another for "Reply To All". All you do is add these subs to a module in Outlook, then set up a toolbar button to call each macro (see Resend This Message page for instructions). When the subs run, you just press 1 if you want to insert the recipient's name at the top, or press 2 if you want a standard greeting line (which self-adjusts depending on time of day). Also if you use the "Reply To All" code, be sure to replace my name with yours (or whatever display name you use to send email from), so you don't send a copy of the message to yourself.
-
Sub InsertNameInReply()
-
-
Dim Msg As Outlook.MailItem
-
Dim MsgReply As Outlook.MailItem
-
Dim strGreetName As String
-
Dim lGreetType As Long
-
-
' set reference to open/selected mail item
-
On Error Resume Next
-
Select Case TypeName(Application.ActiveWindow)
-
Case "Explorer"
-
Set Msg = ActiveExplorer.Selection.Item(1)
-
Case "Inspector"
-
Set Msg = ActiveInspector.CurrentItem
-
Case Else
-
End Select
-
On Error GoTo 0
-
-
If Msg Is Nothing Then GoTo ExitProc
-
-
' figure out greeting line
-
On Error Resume Next
-
lGreetType = InputBox("How to greet:" & vbCr & vbCr & "Type '1' for name, '2' for time of day")
-
On Error GoTo 0
-
-
If (lGreetType <> 1) And (lGreetType <> 2) Then GoTo ExitProc
-
-
If lGreetType = 1 Then
-
strGreetName = Left$(Msg.SenderName, InStr(1, Msg.SenderName, " ") - 1)
-
ElseIf lGreetType = 2 Then
-
Select Case Time
-
Case Is <0.5
-
strGreetName = "Good morning"
-
Case 0.5 To 0.75
-
strGreetName = "Good afternoon"
-
Case Else
-
strGreetName = "Good evening"
-
End Select
-
End If
-
-
Set MsgReply = Msg.Reply
-
-
With MsgReply
-
.Subject = "RE:" & Msg.Subject
-
.HTMLBody = strGreetName & "," & "<br />" & .HTMLBody
-
.Display
-
End With
-
-
ExitProc:
-
Set Msg = Nothing
-
Set MsgReply = Nothing
-
strGreetName = vbNullString
-
End Sub
-
Sub InsertNameInReplyToAll()
-
-
Dim Msg As Outlook.MailItem
-
Dim MsgReply As Outlook.MailItem
-
Dim strGreetName As String
-
Dim sRecipient As Outlook.Recipient
-
Dim lGreetType As Long
-
-
' set reference to open/selected mail item
-
On Error Resume Next
-
Select Case TypeName(Application.ActiveWindow)
-
Case "Explorer"
-
Set Msg = ActiveExplorer.Selection.Item(1)
-
Case "Inspector"
-
Set Msg = ActiveInspector.CurrentItem
-
Case Else
-
End Select
-
On Error GoTo 0
-
-
If Msg Is Nothing Then GoTo ExitProc
-
-
' figure out greeting line
-
On Error Resume Next
-
lGreetType = InputBox("How to greet:" & vbCr & vbCr & "Type '1' for name, '2' for time of day")
-
On Error GoTo 0
-
-
If (lGreetType <> 1) And (lGreetType <> 2) Then GoTo ExitProc
-
-
If lGreetType = 1 Then
-
strGreetName = Left$(Msg.SenderName, InStr(1, Msg.SenderName, " ") - 1)
-
ElseIf lGreetType = 2 Then
-
Select Case Time
-
Case Is <0.5
-
strGreetName = "Good morning"
-
Case 0.5 To 0.75
-
strGreetName = "Good afternoon"
-
Case Else
-
strGreetName = "Good evening"
-
End Select
-
End If
-
-
Set MsgReply = Msg.Reply
-
-
With MsgReply
-
-
' add original recipient(s) to CC field
-
For Each sRecipient In Msg.Recipients
-
If sRecipient.Name <> "Jimmy Pena" Then
-
Set sRecipient = .Recipients.Add(sRecipient.Name)
-
With sRecipient
-
.Type = olCC
-
.Resolve
-
End With
-
End If
-
Next sRecipient
-
-
.Subject = "RE:" & Msg.Subject
-
.HTMLBody = strGreetName & "," & "<br />" & .HTMLBody
-
.Display
-
End With
-
-
ExitProc:
-
Set Msg = Nothing
-
-
Set MsgReply = Nothing
-
strGreetName = vbNullString
-
End Sub
Enjoy,
JP
Print This Post
|
Email This Post
|
Permalink
|
Filed Under: Outlook, VBA
Tags: auto insert name, Reply To All
This post has 75 views since September 6, 2008 – 4:25 pm.






