ASP CDO Cómo agregar un cheque condicional (si) para ignorar un cuadro de texto vacío y saltos de línea

StackOverflow https://stackoverflow.com//questions/21021282

  •  21-12-2019
  •  | 
  •  

Pregunta

Estoy usando Classic ASP para que el usuario complete un formulario en línea que luego envía un correo electrónico.

En el formulario hay algunos cuadros de texto de entrada que probablemente estarán en blanco. En mi salida de correo electrónico he enumerado:

box1: respuesta

Box2: respuesta

Box3: "en blanco"

Box4: "en blanco"

El siguiente párrafo del correo electrónico comienza aquí ...

Quiero que el código ignore el Box3 y 4 y la línea se rompe y se mueva hacia abajo hasta el siguiente párrafo.

box1: respuesta

Box2: Respuesta

El siguiente párrafo del correo electrónico comienza aquí ...

He agregado mi código a continuación. Por favor, mire el "OS1" donde he agregado el cheque condicional. Soy consciente de que es desordenado, pero soy un novato en Asp.

Si esta es una respuesta fácil, tal vez alguien también pueda responder cómo puedo mover la sección HTMLBody a la línea a continuación para poder dejarlo más fácil de leer, ya que está todo en una línea. Si trato de moverme a la siguiente línea e ingrese el texto del cuerpo, el formulario no funciona.

<!-- 
METADATA 
TYPE="typelib" 
UUID="CD000000-8B95-11D1-82DB-00C04FB1625D"  
NAME="CDO for Windows 2000 Library" 
-->  

<%
semaila = request.form("first name")
semailb = request.form("surname")
broker = request.form("broker name")
cust = request.form("cust name")
sapp = request.form("app number")
' Checks that the form value os1 is not empty, then appends the form value plus linebreaks,
' otherwise it is left empty.
If request.form("os1") <> "" Then
os1 = request.form("os1") + "<br><br>"
Else
os1 = "";
End If
os2 = request.form("os2")
os3 = request.form("os3")
os4 = request.form("os4")
os5 = request.form("os5")
os6 = request.form("os6")
os7 = request.form("os7")
sadded = request.form("added")



Set cdoConfig = CreateObject("CDO.Configuration")  

With cdoConfig.Fields  
    .Item(cdoSendUsingMethod) = cdoSendUsingPort  
    .Item(cdoSMTPServer) = "00.000.00.000"  
    .Update  

End With 

With cdoMessage 

' Checks that the form value os1 is not empty, then appends the form value plus line     breaks,
' otherwise it is left empty.
If request.form("os1") <> "" Then
os1 = request.form("os1") + "<br><br>"
Else
os1 = "";
End If

Set cdoMessage = CreateObject("CDO.Message")  

With cdoMessage 
    Set .Configuration = cdoConfig 
    .From = "name@example.com"
    .To = "name@example.com" 
    .Subject = QueryType 
    .HTMLBody = "<HTML><head><title></title></head><body><body bgcolor=""white"" TEXT=""black"" ALINK=""black"" VLINK=""black""> <font face=""ariel""> Dear "& broker &", <br><Br>We have today reviewed the mortgage application you submitted to us for your client in the name of: <br><br> <b> Name:</b> "& cust &" &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp <b>Application Number:</b> "& sapp &" <br><br> In order for us to process your application further we need to be in receipt of the following outstanding items and would be grateful if you could arrange to forward these at your earliest convenience. <br><br> "& os1 & " <br><br> "& os2 & " <br><br> "& os3 & " <br><br> "& os4 & " <br><Br> "& os5 & " <br><br> "& os6 & " <br><br> "& os7 & " <br><Br> Other outstanding items that we have chased today....(The rest of the email will follow..) </font></body></HTML>" 
    .Send 

End With 


Set cdoMessage = Nothing  
Set cdoConfig = Nothing  






Response.write "<HTML><head><title></title></head><body><body bgcolor=""#161712"" TEXT=""white"" ALINK=""white"" VLINK=""white""><center><br><br><Br><Br><Br><br><br><br><Br><br><Br><br>Your request has been submitted....<br><br><br><a href = ""javascript:window.close();""> Click here to close window </a> </center></body></HTML>"

%>

¿Fue útil?

Solución

no lo he probado, pero eso debería hacer el truco

dim os1 : os1 = request.form("os1") & ""
dim os2 : os2 = request.form("os2") & ""
dim os3 : os3 = request.form("os3") & ""
dim os4 : os4 = request.form("os4") & ""
dim os5 : os5 = request.form("os5") & ""
dim os6 : os6 = request.form("os6") & ""
dim os7 : os7 = request.form("os7") & ""

With cdoMessage 
    Set .Configuration = cdoConfig 
    .From = "name@example.com"
    .To = "name@example.com" 
    .Subject = QueryType 
    .HTMLBody = "<HTML><head><title></title></head><body><body bgcolor=""white"" TEXT=""black"" ALINK=""black"" VLINK=""black""> <font face=""ariel""> Dear " &_
                broker & ", <br><Br>We have today reviewed the mortgage application you submitted to us for your client in the name of: <br><br> <b> Name:</b> " &_
                cust & " &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp <b>Application Number:</b> " & sapp &_
                " <br><br> In order for us to process your application further we need to be in receipt of the following outstanding items and would be grateful " &_
                "if you could arrange to forward these at your earliest convenience. <br><br> " &_
                iif(os1<>"", os1 & "<br><br>", "") &_
                iif(os2<>"", os2 & "<br><br>", "") &_
                iif(os3<>"", os3 & "<br><br>", "") &_
                iif(os4<>"", os4 & "<br><br>", "") &_
                iif(os5<>"", os5 & "<br><br>", "") &_
                iif(os6<>"", os6 & "<br><br>", "") &_
                iif(os7<>"", os7 & "<br><br>", "") &_
                " <br><Br> Other outstanding items that we have chased today....(The rest of the email will follow..) </font></body></HTML>" 
    .Send 

End With 


function iif(i, j, k)
    if i then iif = j else iif = k
end function

Otros consejos

Cómo verificar "nada" en Solicitar. Forma de otras maneras:

if Len(Request.Form("os1") > 0) Then

o

if Not IsEmpty(Request.Form("os1")) Then

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top