One way:
First set up a signature with the boilerplate text. Then paste this
code in a standard module in the Outlook VBE.
(Note: I did not write this code, it was adapted from outlookcode.com
and rondebruin.nl)
Sub SendBoilerReply()
Call SendStockMsg("Signature name", "Filename/path")
End Sub
Replace "Signature name" with the name of the signature you created,
and replace "Filename/path" with the fully qualified path and filename
of the file you want to attach. For example, if your signature was
named "Boilerplate Client Response" and you were attaching "C:
\ThankYou.PDF", the code would look like this.
Option Explicit
Sub SendBoilerReply()
Call SendStockMsg("Boilerplate Client Response", "C:
\ThankYou.PDF")
End Sub
Create as many signatures as you need, just copy and paste the above
code and change the references accordingly. If you attach the macro to
a toolbar button, it will be even more user friendly (see "How to
assign a macro to a toolbar button" at
http://codeforexcelandoutlook.com/ResendMsg.html
if you need placement assistance).
Then paste in this code in the same module:
Sub SendStockMsg(SigName As String, Optional sFile As String)
Dim myItem As Outlook.MailItem
Dim olNewMailItem As Outlook.MailItem
Dim SigString As String
Dim Signature As String
' get valid ref to current item
On Error Resume Next
Select Case TypeName(Application.ActiveWindow)
Case "Explorer"
Set myItem = ActiveExplorer.Selection.Item(1)
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
SigString = "C:\Documents and Settings\" & Environ("username") & _
"\Application Data\Microsoft\Signatures\" & SigName &
".htm"
If Dir(SigString) <> "" Then
Signature = GetBoiler(SigString)
Else
Signature = ""
End If
Set olNewMailItem = myItem.Reply
olNewMailItem.HTMLBody = Signature & olNewMailItem.HTMLBody
If sFile <> "" Then
olNewMailItem.Attachments.Add(sFile)
End If
olNewMailItem.Display
myItem.UnRead = False
ExitProc:
Set olNewMailItem = Nothing
End Sub
Function GetBoiler(ByVal sFile As String) As String
' from Dick Kusleika
Dim fso As Object
Dim ts As Object
Set fso = CreateObject("Scripting.FileSystemObject")
Set ts = fso.GetFile(sFile).OpenAsTextStream(1, -2)
GetBoiler = ts.ReadAll
ts.Close
End Function
The filename argument is optional, so if you had a stock reply you
wanted to send, but didn't want to include an attachment, this code
would work:
Sub SendBoilerReply()
Call SendStockMsg("Signature name")
End Sub
This code will work if you select one item when viewing your mailbox,
or on the currently open mail item. Note that it looks for the
signature file in this folder:
C:\Documents and Settings\"username"\Application Data\Microsoft
\Signatures\
If your folder is different, change the path accordingly. (search for
"signature name".htm to find the correct folder)
ps- your stock reply sounds a bit like the "bug letter" urban legend
http://www.snopes.com/business/consumer/bedbug.asp
HTH,
JP