Solved

ASP and VBScript Sending Email + confirmation

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

Stressed Out?

Watch some penguins on the livecam!

Question has a verified solution.

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

Dramatic changes are revolutionizing how we build and use technology. Every company is automating, digitizing, and modernizing operations. We need a better, more connected way to work together as teams so we can harness the insights from our system…
When the s#!t hits the fan, you don’t have time to look up who’s on call, draft emails, call collaborators, or send text messages. An instant chat window is definitely the way to go, especially one like HipChat. HipChat is a true business app. An…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Any person in technology especially those working for big companies should at least know about the basics of web accessibility. Believe it or not there are even laws in place that require businesses to provide such means for the disabled and aging p…

705 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