简体   繁体   English

经典ASP HTML电子邮件表单

[英]Classic ASP HTML email form

I'm using Gmails external mail server to send product inquiry forms from my website. 我正在使用Gmails外部邮件服务器从我的网站发送产品查询表单。 The form itself sends fine, however the email that's dispatched doesn't include the product information included in my form. 表单本身可以很好地发送邮件,但是发送的电子邮件不包含我的表单中包含的产品信息。

My simplified form looks like this: 我的简化形式如下:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Free Products</title>
</head>
<body>
<form id="data" name="data" method="post" action="email.asp">
  <div class="myform">
  <input type="hidden" name="PCode" value="Free_Products" />
  <input type="hidden" name="CCode" value="CampaignCode" />
  <input type="hidden" name="MCode" value="CampaignName" />
  <input type="hidden" name="Action" value="Add" />
  <input type="hidden" name="Qty" value="1" />
  <input type="hidden" name="BackURL" value="www.myurl.com" />
  <ul id="cat_box">
  <label for="ProductCode1">Add quantity:</label>
  <input id="ProductCode1" type="text" name="ProductCode1" size="8" maxlength="4" class="qtytext" title="test title">
  <select id="ProductCode2" name="ProductCode2" >
    <option value="0">0</option>
    <option value="1">1</option>
    <option value="2">2</option>
  </select>
  </form>
<div id="dialog" title="Thank you for your order">
  <p>Thank you for your order.</p>
  This order will be dispatched within 14 days.
  </p>
</div>
</body>
</html>

And my asp email script looks like this: 我的asp电子邮件脚本如下所示:

<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>My Form</title>
</head>

<body>
<%

' declare variables
Dim ProductCode1
Dim ProductCode2

' get posted data into variables
ProductCode1 = Trim(Request.Form("ProductCode1"))
ProductCode2 = Trim(Request.Form("ProductCode2"))

' validation
Dim validationOK
validationOK=true
If (Trim(ProductCode1)="") Then validationOK=false
If (Trim(ProductCode2)="") Then validationOK=false
If (validationOK=false) Then Response.Redirect("error.html?" & EmailFrom)

' prepare email body text
Dim Body
Body = Body & "ProductCode1: " & ProductCode1 & VbCrLf
Body = Body & "ProductCode2: " & ProductCode2 & VbCrLf

Const cdoSendUsingPickup = 1 'Send message using the local SMTP service pickup directory. 
Const cdoSendUsingPort = 2 'Send the message using the network (SMTP over the network). 

Const cdoAnonymous = 0 'Do not authenticate
Const cdoBasic = 1 'basic (clear-text) authentication
Const cdoNTLM = 2 'NTLM

Set objMessage = CreateObject("CDO.Message") 
objMessage.Subject = "Example CDO Message" 
objMessage.From = """Me"" <myAddress@gmail.com>" 
objMessage.To = "myAddress@gmail.com" 
objMessage.TextBody = "This is some sample message text.." & vbCRLF & "It was sent using SMTP authentication and SSL."

'==This section provides the configuration information for the remote SMTP server.

objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 

'Name or IP of Remote SMTP Server
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.gmail.com"

'Type of authentication, NONE, Basic (Base64 encoded), NTLM
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = cdoBasic

'Your UserID on the SMTP server
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusername") = "myAddress@gmail.com"

'Your password on the SMTP server
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "MyPassword"

'Server port (typically 25)
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 465 

'Use SSL for the connection (False or True)
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True

'Connection Timeout in seconds (the maximum time CDO will try to establish a connection to the SMTP server)
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60

objMessage.Configuration.Fields.Update

'==End remote SMTP server configuration section==

objMessage.Send
%>
</body>
</html>

Any ideas what I'm missing? 有什么想法我想念的吗? Why isn't my form talking to my asp script? 为什么我的表单不与我的asp脚本对话?

Thanks 谢谢

At the part where it says: 在其中说:

objMessage.TextBody = "This is some sample message text.." & vbCRLF & "It was sent using SMTP authentication and SSL."

You want to change this to 您要将其更改为

objMessage.TextBody = Body

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM