locked
Creating a user email confirmation RRS feed

  • Question

  • User2082661036 posted

    I have a form that passes it's form data to an asp page that processes and sends email.
    One of the forlds in the form is named "Email".  The webmaster also gets a copy of this email, but I need the value in an input field (which the email asp page reads) to match the users email address input.  The form input line reads this:

    <input name="recipients" type="hidden" value="webmaster@domain.com,<%=Request.Form("Email")%>" />

    Thanks!
    ~Bob

    Monday, July 6, 2009 11:36 AM

Answers

  • User-823196590 posted

    In your case you can't use Request.Form("Email") on the same page as <input name="Email" /> because Request.Form is not populated until the form is submitted.

    Just reference Request.Form("Email") in your code on formmailDB.asp where you need to specify the recipient (along with the webmaster address) for the return email.

    • Marked as answer by Anonymous Tuesday, September 28, 2021 12:00 AM
    Wednesday, July 8, 2009 7:10 AM

All replies

  • User-823196590 posted

    I'm having trouble understanding what you need.  Could you explain it differently or with more detail?

    Monday, July 6, 2009 12:10 PM
  • User2082661036 posted

    Essentially I'm taking the value from an input, and placing it into another value on another input which is hidden and the value is used for email address recipients.  The value of that hidden field has email addresses seperated by commas.  I need the email address the user entered to be copied to the hidden value.  I hope this makes more sense.

     BTW: I'm from NJ and moved to Joklahoma 2 years ago.

    Monday, July 6, 2009 1:29 PM
  • User-823196590 posted

    The code you show looks good to me.

    Monday, July 6, 2009 3:58 PM
  • User2082661036 posted

    I thought it was, but when I submit the form, I get an Invalid email address message.

    Monday, July 6, 2009 4:19 PM
  • User-823196590 posted

    What does the resulting HTML show for the input tag?  Should the addresses be comma or semi-colon delimited?

    Tuesday, July 7, 2009 7:03 AM
  • User2082661036 posted

    The result from the formmail.asp page is "No email recipient(s) specified"

    The seperator is comma between the emails as I have other forms with multiple email addresses seperated by commas.

     Thanks!

    Tuesday, July 7, 2009 9:16 AM
  • User-823196590 posted

    The result from the formmail.asp page is "No email recipient(s) specified"

    No ... I mean what HTML does this create?
    <input name="recipients" type="hidden" value="webmaster@domain.com,<%=Request.Form("Email")%>" />

    Tuesday, July 7, 2009 10:51 AM
  • User2082661036 posted

    <input name="recipients" type="hidden" value="webmaster@anydomain.com," />

     Looks like the ASP code is omitted from the value.  It should be after the comma.

    Tuesday, July 7, 2009 12:13 PM
  • User-823196590 posted

    On the initial form tag, is the method GET or POST?  If it's GET, you need to use Request.QueryString("Email") ... Request.Form only works with POST.

    Tuesday, July 7, 2009 1:45 PM
  • User2082661036 posted

    The method is post. 

    Tuesday, July 7, 2009 3:45 PM
  • User-823196590 posted

    We must be missing something then ... I need more details. What are all the pages involved with what forms, what page is that code on, and in what sequence are the pages processed?

    Tuesday, July 7, 2009 4:37 PM
  • User2082661036 posted

    Heres the part of the form - some irrelevant stuff snipped
    Note, this form works and emails me then adds the data to my access database done by formmailDB.asp.  I just need to add the users email address to the "recepients" entered in the form as a confirmation to him.  Thanks!

    <form name="EquipmentRequest" language="Javascript" "action="formmailDb.asp" method="post">
       
    <div align="center">
    <!-- Additional recipients seperated by comma -->
    <input name="recipients" type="hidden" value="user@anydomain.edu,<%= Request.Form("Email") %>" />

    <input name="subject" type="hidden" value="Equipment Request Form" />
    <input name="replyToField" type="hidden" value="webmaster@stgregorys.edu" />
    <!-- Start of Form fields :: Required Fields below -->
    <input name="requiredFields" type="hidden" value="Requestor,Email,Equipment,NeedLocation" />

    This is a row from the table in the form
    <tr>
        <td align="right" style="width: 294px">Email address:</td>
        <td style="width: 294px">
        <input type="text" name="Email" size="32" tabindex="2" />
        </td>
    </tr>

    <input type="submit" value="Submit" />
    </form>

    Tuesday, July 7, 2009 5:28 PM
  • User-1724662499 posted

    If I am understanding correctly, you are asking the user to enter an email address and you want to send an email to the specified email address + another, hidden email address. In this case you can call the email function twice, specifying two different values for the "To" field. Alternatively you can add one recipient to the "To" field, and the other one to the "CC" or "BCC" field. The form might look like:

    <input type="text" name="Email" size="32" tabindex="2" />

    There is no need to echo the user@anydomain.edu in the form. Process this part on the server side.

    The server side handler for the form should include email code that goes along these lines (using CDO.Message class):

    dim oMSG
    set oMSG = CreateObject( "CDO.MESSAGE" )

    'UNCOMMENT FOLLOWING IF YOU ARE SENDING MAIL THROUGH SMTP SERVER
    'oMSG.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
    'oMSG.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "external-smtp-server-name.com.or-its-ip"
    'oMSG.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
    'oMSG.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "smtp-logon-username-here"
    'oMSG.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "smtp-logon-password-here"
    'oMSG.Configuration.Fields.Update

    oMSG.From = "no-reply@anydomain.com"
    oMSG.To = Request.Form("Email")
    oMSG.BCC = "address-that-receivces-a-copy@anydomain.edu"
    oMSG.Subject = "Thank you"

    oMSG.TextBody = "Message text goes here"
    ' -- OR --
    oMSG.HTMLBody = "Message html goes here"

    on error resume next
        oMSG.Send
        if Err.number <> 0 then
            'OOPS, SEND METHOD FAILED
        end if
    on error goto 0
    set oMSG = nothing

    Wednesday, July 8, 2009 2:51 AM
  • User-823196590 posted

    In your case you can't use Request.Form("Email") on the same page as <input name="Email" /> because Request.Form is not populated until the form is submitted.

    Just reference Request.Form("Email") in your code on formmailDB.asp where you need to specify the recipient (along with the webmaster address) for the return email.

    • Marked as answer by Anonymous Tuesday, September 28, 2021 12:00 AM
    Wednesday, July 8, 2009 7:10 AM