Link to home
Start Free TrialLog in
Avatar of gwr477
gwr477

asked on

Send web form to email and value to Paypal

I have an ASP web form that sends a calculated value to PayPal. It works great.  There is other form content on the same form that I would like to be sent in an email before (or after) going to Paypal for processing.  Is there any way to send the form content to an email and send a value to Paypal?
Avatar of Rimvis
Rimvis
Flag of Lithuania image

Hello gwr477,

Do you need help about sending e-mail from ASp? In this case, look here:

How do I send e-mail with CDO?
http://classicasp.aspfaq.com/email/how-do-i-send-e-mail-with-cdo.html

Regards,

Rimvis
Avatar of gwr477
gwr477

ASKER

I know how to send form data to email and I know how to pass a total to Paypal.  What I don't know is how to do both at the same time.
Sorry, but I can't see where is you problem.
How do you pass value to PayPal? On form submit? Just call your email function there.

Do you have problem with sending form content? Take a look here:

A versatile HTML form mail script for classic ASP
http://www.codeproject.com/asp/sendmail.asp
Avatar of gwr477

ASKER

I have a web form that has javascript calculate and display a total.  When I press the submit button, it passes that value to Paypal.  Somehow, I need to also send the rest of the form content to an email.  Does that explain it?
Intead of posting yor form to PayPal, post it to a page on your server for processing. From that page, process and send your email then Response.Redirect to PayPal with your values.  The address you will want to redirect to is https://www.paypal.com/cgi-bin/webscr?cmd=_xclick then pass all your variables with it in the QueryString for example:
https://www.paypal.com/cgi-bin/webscr?cmd=_xclick?business=Me@here.com&item_name=Gizmo&amount=99.99

It is the same address you would want to use if you were too use a link instead of a form to post to PayPal.

Avatar of gwr477

ASKER

The QueryString example would not display.
ASKER CERTIFIED SOLUTION
Avatar of swinslow
swinslow
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial

Now, if you are attempting to make it so the visitor stays on the same page put all this on the same page:

 <%
   If Request("DoStuff") = "Do Stuff" Then
      CustomerName = Request("CustomerName")
      CustomerEmail = Request("CustomerEmail")
      item_name = Request("item_name")
      amount = Request("amount")

      MailBody = "Whatever you want your message to be. " & _
                 "Maybe include: " & _
                 "Customer Name = " & CustomerName & "<br>" & _
                 "Customer Email = " & CustomerEmail & "<br>"
      'Send Mail
      Set ObjNM=CreateObject("CDO.Message")
          ObjNM.Subject = "Your Email Subject"
          ObjNM.From = "Me@here.com"
          ObjNM.To = CustomerEmail
          ObjNM.HTMLBody = MailBody
          ObjNM.Send
      Set ObjNM = Nothing

      PayPalURL = "https://www.paypal.com/cgi-bin/webscr?cmd=_xclick" & _
                  "&business=Me@here.com" & _
                  "&item_name=" & item_name & _
                  "&amount=" & amount
                  'Plus whatever else fields you need to pass
     %>
       <script language="JavaScript">
           window.open("<%=PayPalURL%>","PayPal")
       </script>
     <%
       Response.Write "Thank You For Your Order"
   End If
 %>

 <form name="PayPalForm" method="post">
 <input type="hidden" name="item_name" value="Gizmo Thing">
 <input type="hidden" name="amount" value="99.99">
 Name: <input type="text" name="CustomerName" value="<%=CustomerName%>"><br>
 Email: <input type="text" name="CustomerEmail" value="<%=CustomerEmail%>"><br>
 <input type="submit" name="DoStuff" value="Do Stuff">
 <!- Plus whatever else fields you want or need visible or hidden-->
 </form>


 So anyway, you now have two examples of how to send an email to whoever and post to PayPal from a single form.
 
 Soren
Avatar of gwr477

ASKER

This is the correct solution. Nice work Expert.