Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Add address to "To" field on click

Status
Not open for further replies.

stwaltemyer

IS-IT--Management
Apr 20, 2011
3
US
Hi,

I am creating a new reservation form for my office to use with a calendar. When a user opens the form many form regions are available for filling in. There are also a number of checkboxes that users can choose depending on what their needs are (i.e. "maintenance", "Information Technology", "Help Desk", etc...). This is what I've already built, and I've already got some VBscript code written, but this is going a little beyond my knowledge of VB language.

But now, I want to be able to accomplish the following:

When one of those checkboxes is checked, I want the corresponding email account to be added to the "To" field. So when someone checks the "maintenance" box, email account "maintenance@myBusiness.com" will be added to the "To" field.

Any help is greatly appreciated! Thank you so much!
 
Use the onClick event in your radio input tags. Assuming you are using CDO to send email. Essentially,

VBS
Code:
<script language="VBScript">
   set objEmail = CreateObject("CDO.Message")
   objEmail.From = "stwaltemyer@domain.com"
   objEmail.Subject = "foo"
   objEmail.Textbody = "bar"

   sub addRecipient(strRecipient)
      objEmail.To = objEmail.To & "; " & strRecipient
   end sub
</script>

<input type="radio" onClick="addRecipient('maintenance@domain.com')">Maintenance

-Geates

"I hope I can feel and see the change - stop the bleed inside a feel again. Cut the chain of lies you've been feeding my veins; I've got nothing to say to you!"
-Infected Mushroom
 
Geates,

Thanks for your reply. That definitely points me in the right direction, however, I was not as specific as I should have been.

I'm trying to write this script inside of an Outlook custom form, and because of that, I'm not sure that the CDO will still apply. Is that correct?
 
This is the script I'm working on now. It's puny, and I don't know much VBscript. I do know that it doesn't work ; )

///
Sub CheckBox5_Click()
Set myPage = Item.GetInspector.ModifiedFormPages("Form")
Set myTo = myPage.Controls("_RecipientControl1")
myTo = myTo & "; " & "stwaltemyer@gmail.com"
End Sub
///

Where CheckBox5 is my radius box, the page name is "Form", and the text box for the "To" field is labeled "_RecipientControl1".
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top