これは、電子メールを送信するための ASP コードです。
<%
'declare variables
Dim EmailFrom
Dim EmailTo
Dim Subject
Dim DealerName
Dim DealerNumber
Dim InvoiceNumber
Dim PONumber
Dim InvoiceDate
Dim ModelNumber
Dim SerialNumber
Dim ConditionofUnit
Dim ReasonforRMA
Dim OtherText
Dim ModelNumber2
Dim SerialNumber2
Dim ConditionofUnit2
Dim ReasonforRMA2
Dim OtherText2
Dim ModelNumber3
Dim SerialNumber3
Dim ConditionofUnit3
Dim ReasonforRMA3
Dim OtherText3
Dim ModelNumber4
Dim SerialNumber4
Dim ConditionofUnit4
Dim ReasonforRMA4
Dim OtherText4
Dim ModelNumber5
Dim SerialNumber5
Dim ConditionofUnit5
Dim ReasonforRMA5
Dim OtherText5
Dim ModelNumber6
Dim SerialNumber6
Dim ConditionofUnit6
Dim ReasonforRMA6
Dim OtherText6
Dim ModelNumber7
Dim SerialNumber7
Dim ConditionofUnit7
Dim ReasonforRMA7
Dim OtherText7
Dim ModelNumber8
Dim SerialNumber8
Dim ConditionofUnit8
Dim ReasonforRMA8
Dim OtherText8
Dim ModelNumber9
Dim SerialNumber9
Dim ConditionofUnit9
Dim ReasonforRMA9
Dim OtherText9
Dim ModelNumber10
Dim SerialNumber10
Dim ConditionofUnit10
Dim ReasonforRMA10
Dim OtherText10
' get posted data into variables
EmailFrom = Trim(Request.Form("EmailFrom"))
EmailTo = "ouremail@domain.com"
Subject = "my subject"
DealerName = Trim(Request.Form("DealerName"))
DealerNumber = Trim(Request.Form("DealerNumber"))
InvoiceNumber = Trim(Request.Form("InvoiceNumber"))
PONumber = Trim(Request.Form("PONumber"))
InvoiceDate = Trim(Request.Form("InvoiceDate"))
ModelNumber = Trim(Request.Form("ModelNumber"))
SerialNumber = Trim(Request.Form("SerialNumber"))
ConditionofUnit = Trim(Request.Form("ConditionofUnit"))
ReasonforRMA = Trim(Request.Form("ReasonforRMA"))
OtherText = Trim(Request.Form("OtherText"))
ModelNumber2 = Trim(Request.Form("ModelNumber2"))
SerialNumber2 = Trim(Request.Form("SerialNumber2"))
ConditionofUnit2 = Trim(Request.Form("ConditionofUnit2"))
ReasonforRMA2 = Trim(Request.Form("ReasonforRMA2"))
OtherText2 = Trim(Request.Form("OtherText2"))
ModelNumber3 = Trim(Request.Form("ModelNumber3"))
SerialNumber3 = Trim(Request.Form("SerialNumber3"))
ConditionofUnit3 = Trim(Request.Form("ConditionofUnit3"))
ReasonforRMA3 = Trim(Request.Form("ReasonforRMA3"))
OtherText3 = Trim(Request.Form("OtherText3"))
ModelNumber4 = Trim(Request.Form("ModelNumber4"))
SerialNumber4 = Trim(Request.Form("SerialNumber4"))
ConditionofUnit4 = Trim(Request.Form("ConditionofUnit4"))
ReasonforRMA4 = Trim(Request.Form("ReasonforRMA4"))
OtherText4 = Trim(Request.Form("OtherText4"))
ModelNumber5 = Trim(Request.Form("ModelNumber5"))
SerialNumber5 = Trim(Request.Form("SerialNumber5"))
ConditionofUnit5 = Trim(Request.Form("ConditionofUnit5"))
ReasonforRMA5 = Trim(Request.Form("ReasonforRMA5"))
OtherText5 = Trim(Request.Form("OtherText5"))
ModelNumber6 = Trim(Request.Form("ModelNumber6"))
SerialNumber6 = Trim(Request.Form("SerialNumber6"))
ConditionofUnit6 = Trim(Request.Form("ConditionofUnit6"))
ReasonforRMA6 = Trim(Request.Form("ReasonforRMA6"))
OtherText6 = Trim(Request.Form("OtherText6"))
ModelNumber7 = Trim(Request.Form("ModelNumber7"))
SerialNumber7 = Trim(Request.Form("SerialNumber7"))
ConditionofUnit7 = Trim(Request.Form("ConditionofUnit7"))
ReasonforRMA7 = Trim(Request.Form("ReasonforRMA7"))
OtherText7 = Trim(Request.Form("OtherText7"))
ModelNumber8 = Trim(Request.Form("ModelNumber8"))
SerialNumber8 = Trim(Request.Form("SerialNumber8"))
ConditionofUnit8 = Trim(Request.Form("ConditionofUnit8"))
ReasonforRMA8 = Trim(Request.Form("ReasonforRMA8"))
OtherText8 = Trim(Request.Form("OtherText8"))
ModelNumber9 = Trim(Request.Form("ModelNumber9"))
SerialNumber9 = Trim(Request.Form("SerialNumber9"))
ConditionofUnit9 = Trim(Request.Form("ConditionofUnit9"))
ReasonforRMA9 = Trim(Request.Form("ReasonforRMA9"))
OtherText9 = Trim(Request.Form("OtherText9"))
ModelNumber10 = Trim(Request.Form("ModelNumber10"))
SerialNumber10 = Trim(Request.Form("SerialNumber10"))
ConditionofUnit10 = Trim(Request.Form("ConditionofUnit10"))
ReasonforRMA10 = Trim(Request.Form("ReasonforRMA10"))
OtherText10 = Trim(Request.Form("OtherText10"))
Dim mail
Set mail = Server.CreateObject("CDONTS.NewMail")
mail.To = EmailTo
mail.BodyFormat = 0
mail.MailFormat = 0
mail.From = EmailFrom
mail.Subject = Subject
mail.Body = "This is an email generated." & "<br>" & "<br>" & _
"<b>Dealer Name: </b>" & DealerName & "<br>" & _
"<b>Dealer Number: </b>" & DealerNumber & "<br>" & _
"<b>Invoice Number: </b>" & InvoiceNumber & "<br>" & _
"<b>PO Number: </b>" & PONumber & "<br>" & _
"<b>Invoice Date: </b>" & InvoiceDate & "<br>" & _
"<b>------ ITEM 1 ------</b><br>" & _
"<b>Model Number: </b>" & ModelNumber & "<br>" & _
"<b>Serial Number: </b>" & SerialNumber & "<br>" & _
"<b>Condition of Unit </b>" & ConditionofUnit & "<br>" & _
"<b>Reason for RMA: </b>" & ReasonforRMA & "<br>" & _
"<b>Other Text <i>(If Applicable)</i></b>: " & OtherText & "<br>" & _
"<b>------ ITEM 2 ------</b><br>" & _
"<b>Model Number: </b>" & ModelNumber2 & "<br>" & _
"<b>Serial Number: </b>" & SerialNumber2 & "<br>" & _
"<b>Condition of Unit </b>" & ConditionofUnit2 & "<br>" & _
"<b>Reason for RMA: </b>" & ReasonforRMA2 & "<br>" & _
"<b>Other Text <i>(If Applicable)</i></b>: " & OtherText2 & "<br>" & _
"<b>------ ITEM 3 ------</b><br>" & _
"<b>Model Number: </b>" & ModelNumber3 & "<br>" & _
"<b>Serial Number: </b>" & SerialNumber3 & "<br>" & _
"<b>Condition of Unit </b>" & ConditionofUnit3 & "<br>" & _
"<b>Reason for RMA: </b>" & ReasonforRMA3 & "<br>" & _
"<b>Other Text <i>(If Applicable)</i></b>: " & OtherText3 & "<br>" & _
"<b>------ ITEM 4 ------</b><br>" & _
"<b>Model Number: </b>" & ModelNumber4 & "<br>" & _
"<b>Serial Number: </b>" & SerialNumber4 & "<br>" & _
"<b>Condition of Unit </b>" & ConditionofUnit4 & "<br>" & _
"<b>Reason for RMA: </b>" & ReasonforRMA4 & "<br>" & _
"<b>Other Text <i>(If Applicable)</i></b>: " & OtherText4 & "<br>" & _
"<b>------ ITEM 5 ------</b><br>" & _
"<b>Model Number: </b>" & ModelNumber5 & "<br>" & _
"<b>Serial Number: </b>" & SerialNumber5 & "<br>" & _
"<b>Condition of Unit </b>" & ConditionofUnit5 & "<br>" & _
"<b>Reason for RMA: </b>" & ReasonforRMA5 & "<br>" & _
"<b>Other Text <i>(If Applicable)</i></b>: " & OtherText5 & "<br>" & _
"<b>------ ITEM 6 ------</b><br>" & _
"<b>Model Number: </b>" & ModelNumber6 & "<br>" & _
"<b>Serial Number: </b>" & SerialNumber6 & "<br>" & _
"<b>Condition of Unit </b>" & ConditionofUnit6 & "<br>" & _
"<b>Reason for RMA: </b>" & ReasonforRMA6 & "<br>" & _
"<b>Other Text <i>(If Applicable)</i></b>: " & OtherText6 & "<br>" & _
"<b>------ ITEM 7 ------</b><br>" & _
"<b>Model Number: </b>" & ModelNumber7 & "<br>" & _
"<b>Serial Number: </b>" & SerialNumber7 & "<br>" & _
"<b>Condition of Unit </b>" & ConditionofUnit7 & "<br>" & _
"<b>Reason for RMA: </b>" & ReasonforRMA7 & "<br>" & _
"<b>Other Text <i>(If Applicable)</i></b>: " & OtherText7 & "<br>" & _
"<b>------ ITEM 8 ------</b><br>" & _
"<b>Model Number: </b>" & ModelNumber8 & "<br>" & _
"<b>Serial Number: </b>" & SerialNumber8 & "<br>" & _
"<b>Condition of Unit </b>" & ConditionofUnit8 & "<br>" & _
"<b>Reason for RMA: </b>" & ReasonforRMA8 & "<br>" & _
"<b>Other Text <i>(If Applicable)</i></b>: " & OtherText8 & "<br>" & _
"<b>------ ITEM 9 ------</b><br>" & _
"<b>Model Number: </b>" & ModelNumber9 & "<br>" & _
"<b>Serial Number: </b>" & SerialNumber9 & "<br>" & _
"<b>Condition of Unit </b>" & ConditionofUnit9 & "<br>" & _
"<b>Reason for RMA: </b>" & ReasonforRMA9 & "<br>" & _
"<b>Other Text <i>(If Applicable)</i></b>: " & OtherText9 & "<br>" & _
"<b>------ ITEM 10 ------</b><br>" & _
"<b>Model Number: </b>" & ModelNumber10 & "<br>" & _
"<b>Serial Number: </b>" & SerialNumber10 & "<br>" & _
"<b>Condition of Unit </b>" & ConditionofUnit10 & "<br>" & _
"<b>Reason for RMA: </b>" & ReasonforRMA10 & "<br>" & _
"<b>Other Text <i>(If Applicable)</i></b>: " & OtherText10 & "<br>"
mail.Send
' redirect to success page
Response.Redirect("complete.html")
%>
ご覧のとおり、すべてのメールで 10 項目すべてを送信する代わりに、実際に値が入力された項目のみを送信する方法を知っている人はいますか? 1 つの項目に記入するだけで、最大 10 個の項目を実行できます。
編集:これを次のように変更しました:
Dim mail
Set mail = Server.CreateObject("CDONTS.NewMail")
mail.To = EmailTo
mail.BodyFormat = 0
mail.MailFormat = 0
mail.From = EmailFrom
mail.Subject = Subject
If Request.Form("ModelNumber2") <> "" Then
mail.Body = "This is an email generated." & "<br>" & "<br>" & _
"<b>Dealer Name: </b>" & DealerName & "<br>" & _
"<b>Dealer Number: </b>" & DealerNumber & "<br>" & _
"<b>Invoice Number: </b>" & InvoiceNumber & "<br>" & _
"<b>PO Number: </b>" & PONumber & "<br>" & _
"<b>Invoice Date: </b>" & InvoiceDate & "<br>" & _
"<b>------ ITEM 1 ------</b><br>" & _
"<b>Model Number: </b>" & ModelNumber & "<br>" & _
"<b>Serial Number: </b>" & SerialNumber & "<br>" & _
"<b>Condition of Unit </b>" & ConditionofUnit & "<br>" & _
"<b>Reason for RMA: </b>" & ReasonforRMA & "<br>" & _
"<b>Other Text <i>(If Applicable)</i></b>: " & OtherText & "<br>" & _
"<b>------ ITEM 2 ------</b><br>" & _
"<b>Model Number: </b>" & ModelNumber2 & "<br>" & _
"<b>Serial Number: </b>" & SerialNumber2 & "<br>" & _
"<b>Condition of Unit </b>" & ConditionofUnit2 & "<br>" & _
"<b>Reason for RMA: </b>" & ReasonforRMA2 & "<br>" & _
"<b>Other Text <i>(If Applicable)</i></b>: " & OtherText2 & "<br>"
ElseIf Request.Form("ModelNumber2") <> "" And Request.Form("ModelNumber3") <> "" Then
mail.Body = "This is an email generated." & "<br>" & "<br>" & _
"<b>Dealer Name: </b>" & DealerName & "<br>" & _
"<b>Dealer Number: </b>" & DealerNumber & "<br>" & _
"<b>Invoice Number: </b>" & InvoiceNumber & "<br>" & _
"<b>PO Number: </b>" & PONumber & "<br>" & _
"<b>Invoice Date: </b>" & InvoiceDate & "<br>" & _
"<b>------ ITEM 1 ------</b><br>" & _
"<b>Model Number: </b>" & ModelNumber & "<br>" & _
"<b>Serial Number: </b>" & SerialNumber & "<br>" & _
"<b>Condition of Unit </b>" & ConditionofUnit & "<br>" & _
"<b>Reason for RMA: </b>" & ReasonforRMA & "<br>" & _
"<b>Other Text <i>(If Applicable)</i></b>: " & OtherText & "<br>" & _
"<b>------ ITEM 2 ------</b><br>" & _
"<b>Model Number: </b>" & ModelNumber2 & "<br>" & _
"<b>Serial Number: </b>" & SerialNumber2 & "<br>" & _
"<b>Condition of Unit </b>" & ConditionofUnit2 & "<br>" & _
"<b>Reason for RMA: </b>" & ReasonforRMA2 & "<br>" & _
"<b>Other Text <i>(If Applicable)</i></b>: " & OtherText2 & "<br>" & _
"<b>------ ITEM 3 ------</b><br>" & _
"<b>Model Number: </b>" & ModelNumber3 & "<br>" & _
"<b>Serial Number: </b>" & SerialNumber3 & "<br>" & _
"<b>Condition of Unit </b>" & ConditionofUnit3 & "<br>" & _
"<b>Reason for RMA: </b>" & ReasonforRMA3 & "<br>" & _
"<b>Other Text <i>(If Applicable)</i></b>: " & OtherText3 & "<br>"
'ElseIf Request.Form("ModelNumber4") = "" Then
'ElseIf Request.Form("ModelNumber5") = "" Then
'ElseIf Request.Form("ModelNumber6") = "" Then
'ElseIf Request.Form("ModelNumber7") = "" Then
'ElseIf Request.Form("ModelNumber8") = "" Then
'ElseIf Request.Form("ModelNumber9") = "" Then
'ElseIf Request.Form("ModelNumber10") = "" Then
Else
mail.Body = "This is an email generated." & "<br>" & "<br>" & _
"<b>Dealer Name: </b>" & DealerName & "<br>" & _
"<b>Dealer Number: </b>" & DealerNumber & "<br>" & _
"<b>Invoice Number: </b>" & InvoiceNumber & "<br>" & _
"<b>PO Number: </b>" & PONumber & "<br>" & _
"<b>Invoice Date: </b>" & InvoiceDate & "<br>" & _
"<b>------ ITEM 1 ------</b><br>" & _
"<b>Model Number: </b>" & ModelNumber & "<br>" & _
"<b>Serial Number: </b>" & SerialNumber & "<br>" & _
"<b>Condition of Unit </b>" & ConditionofUnit & "<br>" & _
"<b>Reason for RMA: </b>" & ReasonforRMA & "<br>" & _
"<b>Other Text <i>(If Applicable)</i></b>: " & OtherText & "<br>"
End If
mail.Send
しかし、3 つの項目を入力しても、2 つの項目のメールしか送信されません。ここで何が欠けていますか?