Foros del Web » Programando para Internet » ASP Clásico »

ayuda por favor

Estas en el tema de ayuda por favor en el foro de ASP Clásico en Foros del Web. Tengo una consulta: El siguiente codigo es el final de un carrito de compras donde manda los tatos por email, el problema es que en ...
  #1 (permalink)  
Antiguo 29/07/2003, 20:22
 
Fecha de Ingreso: julio-2003
Mensajes: 70
Antigüedad: 20 años, 11 meses
Puntos: 0
ayuda por favor

Tengo una consulta:
El siguiente codigo es el final de un carrito de compras donde manda los tatos por email, el problema es que en mi correo no recibo nada, no se si tengo algo mal en el código o no.
Cómo puedo darme cuenta, alguien me puede dar algun servidor gratuito donde probarlo
Gracias
<!-- #include file="db.asp" -->
<!-- #include file="functions.asp" -->
<%


Response.Buffer = true
For Each key in Request.Form
strname = key
strvalue = Request.Form(key)
Session(strname) = strvalue
Next

Dim arrCart, scartItem
arrCart = Session("MyCart")
scartItem = Session("cartItem")
if scartItem = 0 then
Response.Redirect "error.asp?msg=" & Server.URLEncode ("Su session pasó el tiempo de espera, complete nuevamente los datos.")
end if

If Request.Form("cardno") = "" Then
Response.Redirect "checkout.asp?msg=" & Server.URLEncode ("Please fill in a correct credit card number.")


Elseif Request.Form("cardname") = "" Then
Response.Redirect "checkout.asp?msg=" & Server.URLEncode ("Please fill in a correct credit card name.")

Else

strTotal = Cstr(Request.Form("ordertotal"))
intTotal = Replace(strTotal,",",".")

imonth = Request.Form("expMonth")
iyear = Request.Form("expYear")
'use one of the following date formats: mm/dd/yyyy OR dd/mm/yyyy
'if your server's settings are dd/mm/yyyy, please put a single quote in front of next line
expDate = imonth & "/" & "28" & "/" & iyear
'and remove single quote on next line:
'expDate = "28" & "/" & imonth & "/" & iyear

'On error resume next
sqlAdd = "INSERT INTO orders(ocustomerid,odate,orderamount,ocardtype,oca rdno,"
sqlAdd = sqlAdd & "ocardname,ocardexpires,ocardaddress"
If Not Request.Form("shipaddress")="" then
sqlAdd = sqlAdd & ",oshipaddress,oshiptown,oshipzip,oshipstate,oship country"
End If
sqlAdd = sqlAdd & ") VALUES("
sqlAdd = sqlAdd & Session("customerid") & ",#" & Date & "#," & intTotal
sqlAdd = sqlAdd & ",'" & Request.Form("paymentm") & "','" & Request.Form("cardno") & "'"
sqlAdd = sqlAdd & ",'" & TwoSingleQ(Request.Form("cardname")) & "',#" & expDate & "#"
sqlAdd = sqlAdd & ",'" & TwoSingleQ(Request.Form("cardaddress")) & " '"
If Not Request.Form("shipaddress")="" then
sqlAdd = sqlAdd & ",'" & TwoSingleQ(Request.Form("shipaddress")) & "'"
sqlAdd = sqlAdd & ",'" & TwoSingleQ(Request.Form("shiptown")) & " '"
sqlAdd = sqlAdd & ",'" & Request.Form("shipzip") & " '"
sqlAdd = sqlAdd & ",'" & Request.Form("shipstate") & " '"
sqlAdd = sqlAdd & ",'" & Request.Form("shipcountry") & " '"
End If
sqlAdd = sqlAdd & ")"

call openConn()
dbc.execute sqlAdd, intAffected

if dbc.Errors.count > 0 then
call closeConn()
Response.Redirect "error.asp?msg=" & server.URLEncode("Error occurred sending info to Database. Please contact us.")
elseif intAffected = 1 then
Dim oid, sqlo
sqlo = "SELECT max(orderID) FROM orders"
Set rso = dbc.Execute(sqlo)
oid = Cint(rso(0))
rso.Close

If oid < 1 Then
call closeConn()
Response.Redirect "error.asp?msg=" & Server.URLEncode ("Error: No order id.")
Else
'insert order items into oitems table
For i = 1 To scartItem
sqlOItem = "INSERT INTO oitems(orderid,catalogid,numitems) VALUES("
sqlOItem = sqlOItem & oid
sqlOItem = sqlOItem & "," & arrCart(cProductid,i)
sqlOItem = sqlOItem & "," & arrCart(cQuantity,i)
sqlOItem = sqlOItem & ")"
dbc.execute sqlOItem
Next
If dbc.Errors.Count > 0 then
call closeConn()
Response.Redirect "error.asp?msg=" & Server.URLEncode ("Not succeeded. Error: ") & dbc.Error.Description
else
'send mail to merchant, use function mailMerchant
blnMail = mailMerchant("[email protected]",oid,nosmtp)
if blnMail = false then
call closeConn()
Response.Redirect "error.asp?msg=" & Server.URLEncode ("Could not send mail to merchant.")
end if
end if
End if
else
call closeConn()
Response.Redirect "error.asp?msg=" & Server.URLEncode ("Order information could not be sent to database. Please try again later.")
end if
If dbc.Errors.Count > 0 then
dbc.Close
set dbc = nothing
Response.Redirect "error.asp?msg=" & Server.URLEncode ("Not succeeded. Error: ") & dbc.Error.Description
Else
dbc.close
set dbc = nothing
Response.Redirect "thanks.asp"
End If
End If

function mailMerchant(merchantmail,orderid,smtpServer)
'get client info from DB
set cmd = server.CreateObject("ADODB.Command")
cmd.ActiveConnection = dbc
cmd.CommandText = "qryOrderInfo"
cmd.CommandType = adCmdStoredProc
set param = cmd.CreateParameter("oid",adInteger,adParamInput,4 )
cmd.Parameters.Append param
cmd("oid") = orderid

'build message body strBody
set rs = server.CreateObject("ADODB.recordset")
set rs = cmd.Execute
if not rs.eof then
strBody = "Online order by a.shopKart on " & rs("odate") & vbCrLf & vbCrLf
strBody = strBody & "Customer info:" & vbCrLf
strBody = strBody & rs("cfirstname") & vbCrLf
strBody = strBody & rs("clastname") & vbCrLf
strBody = strBody & rs("cemail") & vbCrLf
strBody = strBody & rs("caddress") & " - " & rs("caddress2") & vbCrLf
strBody = strBody & rs("ctown") & vbCrLf
strBody = strBody & rs("czip") & vbCrLf
strBody = strBody & rs("cstate") & vbCrLf
strBody = strBody & rs("ccountry") & vbCrLf
strBody = strBody & rs("cphone") & vbCrLf & vbCrLf

strBody = strBody & "Credit card info:" & vbCrLf
strBody = strBody & rs("ocardtype") & vbCrLf
strBody = strBody & left(rs("ocardno"),4) & "..." & vbCrLf
strBody = strBody & rs("ocardname") & vbCrLf
strBody = strBody & rs("ocardexpires") & vbCrLf & vbCrLf

strBody = strBody & "Ordered items:" & vbCrLf
strBody = strBody & "Code" & vbTab & "Item" & vbTab & "No." & vbTab & "Price" & vbCrLf
strBody = strBody & "-------------------------------------------------------" & vbCrLf
dblOrderTotal = 0
while not rs.EOF
strBody = strBody & rs("ccode") & vbTab & rs("cname") & vbTab
lineTotal = rs("cprice")*rs("numitems")
strBody = strBody & rs("numitems") & vbTab & lineTotal & vbCrLf
dblOrderTotal = dblOrderTotal + lineTotal
rs.MoveNext
wend
strBody = strBody & "-------------------------------------------------------" & vbCrLf
strBody = strBody & "Total: " & dblOrderTotal & vbCrLf
strBody = strBody & vbCrLf & vbCrLf

rs.Close
set rs = nothing
set cmd = nothing

'use CDONTS to send mail
set Mailer = Server.CreateObject("CDONTS.NewMail")
mailer.From = merchantmail
Mailer.To = merchantmail
Mailer.Subject = "Online order (a.shopKart)"
Mailer.Body = strBody
Mailer.Send
if Err.number > 0 then
mailMerchant = false
else
mailMerchant = true
end if

'OR use ASPMail - choose your own
'Set Mailer = Server.CreateObject ("SMTPsvg.Mailer")
'Mailer.FromName = "a.shopKart"
'Mailer.FromAddress = merchantmail
'Mailer.Subject = "a.shopKart Order"
'Mailer.BodyText = strBody
'Mailer.RemoteHost = smtpServer

'Mailer.AddRecipient "", merchantmail
'if Mailer.SendMail then
' Message sent sucessfully
' mailMerchant = true
'else
' Message send failure
' mailMerchant = false
'end if
else
rs.Close
set rs = nothing
set cmd = nothing
mailMerchant = false
end if

end function

%>cmd = nothing
mailMerchant = false
end if

end function

%>
__________________
NormaB
  #2 (permalink)  
Antiguo 21/08/2003, 19:23
 
Fecha de Ingreso: agosto-2003
Mensajes: 4
Antigüedad: 20 años, 9 meses
Puntos: 0
Hola Norma... has probado enviar un mail simple, con el CDONTS? es decir, sin usar lo de la base de datos, etc., esto solo para segurarte que CDO esta bien configurado y funcionando correctamente... haz esta prueba y seguimos viendo el issue, te parece?

Ruddy
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 02:02.