Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

ASP and VBScript Sending Email + confirmation

Posted on 2006-06-27
4
Medium Priority
?
335 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 2000 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

There’s a good reason for why it’s called a homepage – it closely resembles that of a physical house and the only real difference is that it’s online. Your website’s homepage is where people come to visit you. It’s the family room of your website wh…
CTAs encourage people to do something specific to show interest in your company, product or service. Keep reading to learn why CTAs should always be thought of as extremely important, albeit small, sections of websites.
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…
The is a quite short video tutorial. In this video, I'm going to show you how to create self-host WordPress blog with free hosting service.
Suggested Courses

636 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