如何包含CDO主机名和端口?

时间:2012-06-01 13:29:13

标签: vbscript asp-classic cdo.message

如何将主机名和端口25传递给此vbscript?

<html>

<head>
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>New Page 1</title>
</head>
<%
if request("Name") ="" or request("Email") ="" or request("Address") ="" then 
response.redirect("catalogue_error.html")
end if


Subject="Enquiry from test test"
BodyText=" <div id='textareazzz' style='font-family:arial'> <br>"
BodyText=BodyText+"<strong>Line of Business:</strong>"&request("Line of Business")&"<br>"
BodyText=BodyText+"<strong>Name:</strong>"&request("Name")&"<br>"
BodyText=BodyText+"<strong>Company:</strong>"&request("Company")&"<br>"
BodyText=BodyText+"<strong>Address:</strong>"&request("Address")&"<br>"
BodyText=BodyText+"<strong>Post Code:</strong>"&request("Post Code")&"<br>"
BodyText=BodyText+"<strong>Contact Tel No:</strong>"&request("Contact Tel No")&"<br>"
BodyText=BodyText+"<strong>Email:</strong>"&request("Email")&"<br>"
BodyText=BodyText+"</div>"
Response.write(BodyText)


Dim objMessage
Set objMessage = Server.CreateObject("CDO.Message")

With objMessage
.To = "test@hotmail.co.uk"
'.To = "test@hotmail.co.uk"
.From = "test@test.co.uk"
.Subject = Subject
.HTMLBody = BodyText
.Send
End With

Set objMessage = Nothing
response.redirect("cdo.html")
%>
<body>
<%=request("From")%><br>
<%=request("Subject")%><br>
<%=request("Message")%><br>
</body>

</html>

1 个答案:

答案 0 :(得分:1)

您可以通过Configuration.Fields对象的CDO.Message属性配置电子邮件发送选项:

objMessage.Configuration.Fields.Item _
    ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 ' cdoSendUsingPort
objMessage.Configuration.Fields.Item _
    ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "server"
objMessage.Configuration.Fields.Item _
    ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25