INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Sending form information using a CDO email object

Sending form information using a CDO email object

(OP)
Hello,

I have an ASP page that contains a form. Once the user submits the form, the information is sent to an email address using a CDO email object and a popup message appears saying that the information has been sent.

What I would like to do is to create an onclick event on the submit button that will trigger the creation of the email and the sending of the information. Since the email generation code is in the same page as the form that would prevent the email from being sent if the form is empty.

The submit button is an image and so far I haven't been able to get it to work.

CODE


<input type="image" name="submit" src="images/submit.png" width="115" height="39"/>

if request.Form("submit")<>"" then
                
                
                Set myMail=Server.CreateObject("CDO.Message")
           myMail.Subject="Contact Request"
           myMail.From = Request.Form("email")
            myMail.To= "xxx@xxx.com"
            'myMail.CC="xxx@xxx.com"
            myMail.TextBody = "Name:"& Request.Form("name")& vbcrlf & vbcrlf & _
                "Email:" & Request.Form("email") & vbcrlf & vbcrlf &  _
                 "Telephone:" & Request.Form("telephone") & vbcrlf & vbcrlf & _
                 "Length of separation:" & Request.Form("separation") & vbcrlf & vbcrlf & _
                 "Location:" & Request.Form("location") & vbcrlf & vbcrlf & _
             "Other location:" & Request.Form("other_location") & vbcrlf & vbcrlf
                 "Divorce Agreed:" & Request.Form("divorce_agreement") & vbcrlf & vbcrlf & _
             "Comments:" & Request.Form("comments")
             myMail.Configuration.Fields.Item _
             ("http://schemas.microsoft.com/cdo/configuration/sendusing")=2
             'Name or IP of remote SMTP server
             myMail.Configuration.Fields.Item _
             ("http://schemas.microsoft.com/cdo/configuration/smtpserver") _
                 ="127.0.0.1"
             'Server port
              myMail.Configuration.Fields.Item _
              ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") _
              =25
              myMail.Configuration.Fields.Update
              myMail.Send
              set myMail=nothing
              %>
            <script language="javascript"type="text/javascript">
            alert("Thank you! Your request has been sent. One of our team members will be in touch with you shortly")
        </script>
            <%end if%>
 

RE: Sending form information using a CDO email object

CDO is server side, javascript is clientside.

ASP code has completed before javascript even STARTS to run, and ASP code will not run again until an HTTP request is sent to the server.



Chris.

Indifference will be the downfall of mankind, but who cares?
Time flies like an arrow, however, fruit flies like a banana.
Webmaster Forum

RE: Sending form information using a CDO email object

(OP)
Hi Chris,

Thank you for your answer.

How could I write this for it to work?

Thanks.

RE: Sending form information using a CDO email object

Check the error message returned from obj.send() if it is 0 show the success message.

http://www.candsdesign.co.uk/articles/code/asp/send-email/cdosys/ an article I did many moons ago.

Chris.

Indifference will be the downfall of mankind, but who cares?
Time flies like an arrow, however, fruit flies like a banana.
Webmaster Forum

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close