Solved

ASP and VBScript Sending Email + confirmation

Posted on 2006-06-27
4
327 Views
Last Modified: 2008-02-01
Hello.

I have run into a few issues , and here is what I have so far, edited a bit for context
<body>
<%
Function mailit(X)
~~~~~~~~
~~~~~~~~
            With Fields
                   .Item(cdoSendUsingMethod)       = 1
                   .Item(cdoSMTPServer)            = "ipgoeshere"
                   .Item(cdoSMTPServerPort)        = 25
                   .Item(cdoSMTPConnectionTimeout) = 10
                   .Item(cdoSMTPAuthenticate)      = cdoBasic
                   .Update
            End With
            Body = "<table border=""0"" width=""414"" id=""UserInfo"">" & vbCrLf
            Body = Body _
                        & "<p>~~~~~
                                         ~~~~~~~


            Set objMessage = Server.CreateObject("CDO.Message")

            Set objMessage.Configuration = objConfig
            With objMessage
                   .To       = "metwo@me.com"
                   .From     = "me@me.com"
                   .Subject  = Heading
                   .HTMLBody = Body
                   .Send
            End With

            Set cdoMessage=Nothing
            Set cdoConfig=Nothing
End Function
%>

<input type='button' name='BuyNow' value='Submit' onClick=<%=mailit("Yes")%>>


<%=mailit("No")%>

</body>


My problem comes in that On form load (server side ASP page) it hits both mailit("Yes") and mailit("No"), and the onclick does nothing, as I get an email for both of them regardless of whether they are commented out or not.

I want it to do mailit("No") on page load, and mailit("Yes") on button click.  

Ideally; i would like a msg box popup verification on button click after it sends the email; but a simple redirect would do; but I need to get them to send the email at the correct times first.  Any help would be greatly appreciated.

Thanks in advance
-chris
0
Comment
Question by:dsa_erie
  • 2
4 Comments
 
LVL 2

Expert Comment

by:wilniuk
ID: 16999437
The string <%=mailit("Yes")%> inserts the result of the function call, not the function call itself. You cannot place asp finction in an onClick event. Use form, iframe or open a new window with parametrized asp to call mailit indirectly in an onClick event.
0
 
LVL 13

Accepted Solution

by:
PraxisWeb earned 500 total points
ID: 17001193
What you would need to do is create a form that references itself and then process the info from the user.

This should get you started:

<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
    <title>Untitled Page</title>
</head>
<%
IF (Request.QueryString.Count > 0 OR Request.Form.Count > 0) THEN
    IF (Request("yes")<>"") THEN
      Response.Write "You bought it!"
      'PUT YOUR YES EMAIL TEXT HERE
    ELSE
      Response.Write "Why don't you want it?"
      'PUT YOUR NO EMAIL TEXT HERE
    END IF
END IF
 %>
<body>
    <form name="buyme" method=get>
        <input type="submit" name="yes" value="Buy Now" />
        <input type="submit" name="no" value="No Thanks" />
    </form>
</body>
</html>
0
 

Author Comment

by:dsa_erie
ID: 17011818
Thank you, that half works.

I am going from Page1.asp, On click that goes to Page2.asp, where the code I quoted above is listed.  On load I have it sending the email; and on click sending the email; but onlick it does not have the users data from the previos page still.

What would be the best method to keep the information on the form whn clicking on the input button again?   Currently i'm using <% name=Request.Form("name") %> a number of times to pull it in, then using it from there.  On load <%name%> gets the correct value; but on button click blank fields.  Thanks in advance once more.  
0
 

Author Comment

by:dsa_erie
ID: 17012741
All I had to do was create field sof the same name and hide them, while setting the value to whatever is needed.  Worked like a charm.  Thanks for the help.
-chris
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
I've been asked to discuss some of the UX activities that I'm using with my team. Here I will share some details about how we approach UX projects.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now