How to reply with a default template while replacing the name value

0

I am wondering if this is possible at all? I have emails that come with me having to reply to them with the following message

Hello NAME,

Your request has been completed.

Thank you.

is there a way for me to automate this process with a click of a button? Also is there a way for me to populate the NAME with the senders name? currently the senders name appears in the "From" field as follows LastName, FirstName. I would like to replace the NAME variable of my message to FirstName value.

I'm wondering if this possible with Outlook 2003?

Any help would be greatly appreciated.

Thank you.

BaconJuice

Posted 2013-11-19T20:51:59.087

Reputation: 101

Answers

0

Save a template file with your text. In the code it is saved to C drive and named NamePlaceholder.oft . Change as needed.

Open a request before running the code.

Sub CreateReplyFromTemplate()

Dim currItem  As Outlook.mailItem
Dim currItemReply  As Outlook.mailItem
Dim myItem As Outlook.mailItem

Dim commaPositionRight As Long
Dim Firstname As String

Set currItem = ActiveInspector.currentItem
Set currItemReply = currItem.Reply
Set myItem = Application.CreateItemFromTemplate("C:\NamePlaceholder.oft")

myItem.To = currItemReply.To
commaPositionRight = InStrRev(myItem.To, ",")
Firstname = Right(myItem.To, commaPositionRight)

myItem.Subject = currItem.Subject

' if "RE:" or "FW:" on the request,
'  and the client replies there would be an extra "RE:" or "FW:"
If InStr(myItem.Subject, "RE: ") = 1 Or InStr(myItem.Subject, "FW: ") = 1 Then
    myItem.Subject = Right(myItem.Subject, Len(myItem.Subject) - 4)
End If

myItem.HTMLBody = myItem.HTMLBody & currItemReply.HTMLBody
myItem.HTMLBody = Replace(myItem.HTMLBody, "NAME", Firstname)

currItemReply.Close olDiscard
currItem.Close olDiscard

myItem.Display

Set currItemReply = Nothing
Set myItem = Nothing
Set currItem = Nothing

End Sub

If you are unfamiliar with VBA see here http://www.slipstick.com/developer/how-to-use-outlooks-vba-editor/

niton

Posted 2013-11-19T20:51:59.087

Reputation: 1 724