Hello,
I have this macro code which will Reply to email adding recepients email address, sujcect and also addressing them with first name and last name. But i have outlook template and I want to insert recepients name in that template. Is that possible?
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
strGreetName = Mid$(Msg.SenderName, 2 + InStr(1, Msg.SenderName, ", ", Len(Msg.SenderName)) - 1)
Set MsgReply = Msg.Reply
With MsgReply
.Subject = "RE:" & Msg.Subject
.HTMLBody = "<span style=""font-family : verdana;font-size : 10pt""><p>Hello " & strGreetName & ",</p></span>" & .HTMLBody
.Display
End With
ExitProc:
Set Msg = Nothing
Set MsgReply = Nothing
End Sub
I have this macro code which will Reply to email adding recepients email address, sujcect and also addressing them with first name and last name. But i have outlook template and I want to insert recepients name in that template. Is that possible?
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
strGreetName = Mid$(Msg.SenderName, 2 + InStr(1, Msg.SenderName, ", ", Len(Msg.SenderName)) - 1)
Set MsgReply = Msg.Reply
With MsgReply
.Subject = "RE:" & Msg.Subject
.HTMLBody = "<span style=""font-family : verdana;font-size : 10pt""><p>Hello " & strGreetName & ",</p></span>" & .HTMLBody
.Display
End With
ExitProc:
Set Msg = Nothing
Set MsgReply = Nothing
End Sub
Last edited: