Link to home
Start Free TrialLog in
Avatar of Starquest321
Starquest321

asked on

How to customize email form with custom text?

I want to customize my email form with the following capability - add 3-4 buttoms with custom text that depending on the email I can click a button the text would be generated and I can simply hit send. I know its pretty simple to do  . ..but need help.
Thanks.
Avatar of David Lee
David Lee
Flag of United States of America image

Hi, Starquest321.

You don't need a custom form to accomplish this.  It can be done easily enough with a simple bit of scripting.  The advantage to scripting this is that custom forms require all parties to have the custom form.  If scripting sounds like a possibility, then I can provide the code and instructions on how to use it.
Avatar of Starquest321
Starquest321

ASKER

Scripting works well...can you show me?
Ok.  Do you want to create the message with a predefined subject and text in the body, or do you want to insert predefined text in the message?
Predefined text....
Actually can you give me both? And include the ability to put in an attached PDF file.... this can really be useful
Okay, here they are.  Follow these instructions to use them.

1.  Start Outlook
2.  Click Tools->Macro->Visual Basic Editor
3.  If not already expanded, expand Modules and click on Module1
4.  Copy the code below and paste it into the right-hand pane of the VB Editor.
5.  Edit the code as needed.  I've placed comment lines immediately before where changes need to/can be made.  Duplicate the TextInsert macro as needed.  You'll want one for each different chunk of text you might want to insert.
6.  Click the diskette icon on the toolbar to save the changes
7.  Close the VB Editor
8.  Click Tools->Macro->Security
9.  Change the Security Level setting to Medium
10.  Click View->Toolbars->Customize
11.  Click the Toolbars tab
12.  Click New
13.  Name the toolbar
14.  Click the Commands tab
15.  Under Categories click Macros
16.  Under Commands click and hold on the macro Project1.CreateCannedMessage, then drag it out and drop it on the new toolbar.  Repeat this step for each TextInsert macro.
17.  Dock the toolbar somewhere onscreen
18.  You're ready to go
19.  Any time you want to request a receipt just click the toolbar button for this macro.  The macro will only work if it's clicked with a message item open.

The code is very simple.  When you click the button that fires the CreateCannedMessage macro the code will create a new message, set the subject and body with predefined text, and display the resulting message on screen.  When you click a button that fires a TextInsert macro the code enters the text wherever the cursor is currently positioned.  

Sub CreateCannedMessage()
    Dim olkMessage As Outlook.MailItem
    Set olkMessage = Application.CreateItem(olMailItem)
    With olkMessage
        .BodyFormat = olFormatHTML
        'Edit the subject and message body as desired.
        .Subject = "My Subject Text"
        .HTMLBody = "My message text."
        .Display
    End With
    Set olkMessage = Nothing
End Sub

Sub InsertCannedTextIntoMessage(strText As String)
    SendKeys strText, True
End Sub

Sub TextInsert1()
    InsertCannedTextIntoMessage "Text to be inserted."
End Sub
ASKER CERTIFIED SOLUTION
Avatar of David Lee
David Lee
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
You rock! Thanks.
Thanks, and you're welcome.