Solved

ASP and VBScript Sending Email + confirmation

Posted on 2006-06-27
4
328 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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Accessibility and Usability are two concepts that seem to be closely related.  But, too many people seem to have a distorted perception of them. During last five years, those two words have come to the day-to-day work of almost every web develope…
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.
This tutorial demonstrates how to identify and create boundary or building outlines in Google Maps. In this example, I outline the boundaries of an enclosed skatepark within a community park.  Login to your Google Account, then  Google for "Google M…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

920 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

15 Experts available now in Live!

Get 1:1 Help Now