Macro & buttons to reply Dear ..., Regards ...

M

Mark

Thanks to members of these board for help in creating this

For the sake of anyone else who wants to play with it, the following is what
I came up with and it works for me, but no guarantees for anybody else.

I have put buttons on my task bar. Actually I have a few: Dear, Reply_all,
Hi, Hello, Many thanks. All have differing salutations etc. I've also added
shortcut keys to the most used.

Cheers
Mark

(BTW Dear_reply_all uses Set NewMsg = myItem.ReplyAll)


-----------------------

Sub Dear_Name_if()
Dim myItem As Outlook.MailItem
Dim NewMsg As Outlook.MailItem

' get valid ref to current item
On Error Resume Next
Select Case TypeName(Application.ActiveWindow)
Case "Explorer"
Set myItem = ActiveExplorer.Selection.Item(1)
myItem.Display
Case "Inspector"
Set myItem = ActiveInspector.CurrentItem
Case Else
End Select
On Error GoTo 0

If myItem Is Nothing Then
MsgBox "Could not use current item. Please select or open a single
email.", _
vbInformation
GoTo ExitProc

End If

Set NewMsg = myItem.Reply

With NewMsg

NewMsg.BodyFormat = olFormatHTML


..HTMLBody = "<span style=""font-size:11.0pt;font-family:
Arial;color:#1F497D""><p>Regards, Mark" & vbCr & vbCr & vbCr & vbCr & "</p>"
& .HTMLBody

..HTMLBody = "<span style=""font-size:11.0pt;font-family:
Arial;color:#1F497D""><p> " & "</p><br />" & .HTMLBody


If myItem.SenderName, " " Then

..HTMLBody = "<span style=""font-family : Arial;font-size :
11pt;color:#1F497D""><p>Dear " & Left$(myItem.SenderName, InStr(1,
myItem.SenderName, " ") - 1) & ",</p></span>" & .HTMLBody

Else
..HTMLBody = "<span style=""font-family : Arial;font-size :
11pt;color:#1F497D""><p>Dear " & Left$(myItem.SenderName, InStr(1,
myItem.SenderName, "@") - 1) & ",</p></span>" & .HTMLBody

End If


End With

myItem.Close olDiscard

NewMsg.Display


ExitProc:
Set myItem = Nothing
Set NewMsg = Nothing

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top