ASP CDO 조건부 검사를 추가하는 방법 (if) 빈 텍스트 상자 및 줄 바꿈을 무시할 수있는 방법

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

  •  21-12-2019
  •  | 
  •  

문제

사용자가 온라인 양식을 작성하여 전자 메일을 제출하는 클래식 ASP를 사용하고 있습니다.

양식에는 빈 입력 텍스트 상자가 있습니다. 내 이메일 출력에서는 다음과 같습니다.

box1 : 답변


Box2 : 답변


BOX3 : "공백"


Box4 : "공백"

이메일의 다음 단락은 여기에서 시작됩니다 ...

Box3 & 4를 무시하고 줄 바꿈을 무시하고 다음 단락으로 똑바로 움직이게합니다.

box1 : 답변


Box2 : 답변

이메일의 다음 단락은 여기에서 시작됩니다 ...

아래 코드를 추가했습니다. 조건부 검사를 추가 한 "OS1"을보십시오. 나는 그것이 지저분하지만 나는 ASP에서 초보자입니다.

이것이 쉬운 대답이라면 누군가가 HTMLBody 섹션을 아래 줄에 옮길 수있는 방법에 대해서도 답변 할 수 있습니다. 그래서 한 줄에 모두 그대로 읽으려면 쉽게 읽을 수 있습니다. 다음 줄로 이동하고 본문 텍스트를 입력하려고하면 양식이 작동하지 않습니다.

<!-- 
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>"

%>
.

도움이 되었습니까?

해결책

테스트를하지는 않았지만 트릭을 수행해야합니다

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
.

다른 팁

request.form에서 "아무것도"확인 방법 :

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

또는

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top