Solved

ASP and VBScript Sending Email + confirmation

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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Standard for Web Development 3 38
Where can I find... 1 30
When should I use a controller? 3 34
CSS: Making responsive table look nicer 7 24
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.
FAQ pages provide a simple way for you to supply and for customers to find answers to the most common questions about your company. Here are six reasons why your company website should have a FAQ page
This tutorial walks through the best practices in adding a local business to Google Maps including how to properly search for duplicates, marker placement, and inputing business details. Login to your Google Account, then search for "Google Mapmakerā€¦
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

785 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