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
> Hi,
>
[quoted text clipped - 12 lines]
>
> Thanks in advance!
peeweejd - 31 Mar 2008 19:25 GMT
> One way:
>
> First set up asignaturewith the boilerplate text. Then paste this
> code in a standard module in the Outlook VBE.
Thanks for the help. I tried it, but all of the previous text is
wiped out by the signature.
> ps- your stockreplysounds a bit like the "bug letter" urban legend
yeah, I didn't think that I should bore you all with my schmoozing ;-)
Thanks for the help. I may just use the "signature" trick. It's
really too bad that you cannot add an attachment to a signature file.
JP - 31 Mar 2008 19:56 GMT
What do you mean "previous text"? You mean the text of the original
message? In my testing the code replies to the message then inserts
the boilerplate text at the top, exactly as if you had done so
manually. The original text of the message is preserved at the bottom
of the stock reply.
That is what this line does:
olNewMailItem.HTMLBody = Signature & olNewMailItem.HTMLBody
It sets the HTMLBody property of the new message to the text of the
signature (the boilerplate text) then appends the original text of the
reply (as if you had pressed "Reply").
You don't need to add the attachment to the signature. As I mentioned
in the previous message, you can specify an attachment in the call to
the function. This makes it more flexible in that you can have
different boilerplates and attachments for different situations.
HTH,
JP
> > One way:
>
[quoted text clipped - 10 lines]
> Thanks for the help. I may just use the "signature" trick. It's
> really too bad that you cannot add an attachment to a signature file.
Sue Mosher [MVP-Outlook] - 31 Mar 2008 21:36 GMT
That statement won't work as you expect it to, because it puts the signature *outside* the <html><body> and </body></html> tags when instead it needs to go inside -- *and* be completely tagged HTML content. In other words, it takes a bit of text parsing with the Instr(), Mid(), and Left() functions.

Signature
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54
What do you mean "previous text"? You mean the text of the original
message? In my testing the code replies to the message then inserts
the boilerplate text at the top, exactly as if you had done so
manually. The original text of the message is preserved at the bottom
of the stock reply.
That is what this line does:
olNewMailItem.HTMLBody = Signature & olNewMailItem.HTMLBody
It sets the HTMLBody property of the new message to the text of the
signature (the boilerplate text) then appends the original text of the
reply (as if you had pressed "Reply").
You don't need to add the attachment to the signature. As I mentioned
in the previous message, you can specify an attachment in the call to
the function. This makes it more flexible in that you can have
different boilerplates and attachments for different situations.
HTH,
JP
On Mar 31, 2:25 pm, peeweejd <peewe...@gmail.com> wrote:
> On Mar 31, 1:42 pm, JP <jp2...@earthlink.net> wrote:
>
[quoted text clipped - 12 lines]
> Thanks for the help. I may just use the "signature" trick. It's
> really too bad that you cannot add an attachment to a signature file.
JP - 31 Mar 2008 21:52 GMT
Good point Sue, but it still does what the OP wants :-)
--JP
On Mar 31, 4:36 pm, "Sue Mosher [MVP-Outlook]"
<sue...@outlookcode.com> wrote:
> That statement won't work as you expect it to, because it puts the signature *outside* the <html><body> and </body></html> tags when instead it needs to go inside -- *and* be completely tagged HTML content. In other words, it takes a bit of text parsing with the Instr(), Mid(), and Left() functions.
>
[quoted text clipped - 3 lines]
> Jumpstart for Power Users and Administrators
> http://www.outlookcode.com/article.aspx?id=54