CDO.Message.1错误'80040220'配置值无效. msg.send的错误行 [英] CDO.Message.1 error '80040220' The "SendUsing" configuration value is invalid. error line at msg.send

查看:117
本文介绍了CDO.Message.1错误'80040220'配置值无效. msg.send的错误行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<%
option explicit

''---------------------------------------------------------------------------------------------------
''FORM MAIL SCRIPT
''----------------
''usage:
''<form ACTION="sendmail.asp" ...>
''
''hidden fields:
''	redirect	- the url to redirect to when the mail has been sent (REQUIRED)
''	mailto		- the email address of the recipient (separate multiple recipients with commas)  (REQUIRED)
''	cc			- the email address of the cc recipient (separate multiple recipients with commas) (OPTIONAL)
''	bcc			- the email address of the bcc recipient (separate multiple recipients with commas) (OPTIONAL)
''	mailfrom	- the email address of the sender  (REQUIRED)
''	subject		- the subject line of the email  (REQUIRED)
''	message		- the message to include in the email above the field values. not used when a template is being used. (OPTIONAL)
''	template	- specifies a text or html file to use as the email template, relative to the location of the sendmail script. (e.g. ../email.txt)
''				  A template should reference form fields like this: [$Field Name$]
''	html		- if this has the value "yes", the email will be sent as an html email. only used if a template is supplied.
''	testmode	- if this is set to "yes", the email contents will be written to the screen instead of being emailed.
''---------------------------------------------------------------------------------------------------
dim pde : set pde = createobject("scripting.dictionary")
''---------------------------------------------------------------------------------------------------
''PREDEFINED ADDRESSES for the "mailto" hidden field
''if you don''t want to reveal email addresses in hidden fields, use a token word instead and specify
''below which email address it applies to. e.g. <input type="hidden" name="mailto" value="%stratdepartment%">
''ALSO, in the same way, you can use %mailfrom% to hide the originating email address
pde.add "%contactform%", "myemail@someaddress.com"
pde.add "%salesenquiry%", "anotheremail@someaddress.com"
''---------------------------------------------------------------------------------------------------

function getTextFromFile(path)
	dim fso, f, txt
	set fso = createobject("Scripting.FileSystemObject")
	if not fso.fileexists(path) then
		getTextFromFile = ""
		exit function
	end if
	set f = fso.opentextfile(path,1)
	if f.atendofstream then txt = "" else txt = f.readall
	f.close
	set f = nothing
	set fso = nothing
	getTextFromFile = txt
end function

dim redir, mailto, mailfrom, subject, item, body, cc, bcc, message, html, template, usetemplate, testmode
redir = request.form("redirect")
mailto = request.form("mailto")
if pde.exists(mailto) then mailto = pde(mailto)
cc = request.form("cc")
bcc = request.form("bcc")
mailfrom = request.form("mailfrom")
if mailfrom = "" then mailfrom = pde("%mailfrom%")
subject = request.form("subject")
message = request.form("message")
template = request.form("template")
testmode = lcase(request.form("testmode"))="yes"

if len(template) > 0 then template = getTextFromFile(server.mappath(template))
if len(template) > 0 then usetemplate = true else usetemplate = false
dim msg : set msg = server.createobject("CDO.Message")
msg.subject = subject
msg.to = mailto
msg.from = mailfrom
if len(cc) > 0 then msg.cc = cc
if len(bcc) > 0 then msg.bcc = bcc

if not usetemplate then
	body = body & message & vbcrlf & vbcrlf
else
	body = template
end if
for each item in request.form
	select case item
		case "redirect", "mailto", "cc", "bcc", "subject", "message", "template", "html", "testmode"
		case else
			if not usetemplate then
				if item <> "mailfrom" then body = body & item & ": " & request.form(item) & vbcrlf & vbcrlf
			else
				body = replace(body, "[$" & item & "$]", replace(request.form(item),vbcrlf,"<br>"))
			end if
	end select
next

if usetemplate then ''remove any leftover placeholders
	dim rx : set rx = new regexp
	rx.pattern = "\[\$.*\$\]"
	rx.global = true
	body = rx.replace(body, "")
end if

if usetemplate and lcase(request.form("html")) = "yes" then
	msg.htmlbody = body
else
	msg.textbody = body
end if
if testmode then
	if lcase(request.form("html")) = "yes" then
		response.write "<pre>" & vbcrlf
		response.write "Mail to: " & mailto & vbcrlf
		response.write "Mail from: " & mailfrom & vbcrlf
		if len(cc) > 0 then response.write "Cc: " & cc & vbcrlf
		if len(bcc) > 0 then response.write "Bcc: " & bcc & vbcrlf
		response.write "Subject: " & subject & vbcrlf & string(80,"-") & "</pre>"
		response.write body
	else
		response.write "<html><head><title>Sendmail.asp Test Mode</title></head><body><pre>" & vbcrlf
		response.write "Mail to: " & mailto & vbcrlf
		response.write "Mail from: " & mailfrom & vbcrlf
		if len(cc) > 0 then response.write "Cc: " & cc & vbcrlf
		if len(bcc) > 0 then response.write "Bcc: " & bcc & vbcrlf
		response.write "Subject: " & subject & vbcrlf & vbcrlf
		response.write string(80,"-") & vbcrlf & vbcrlf & "<span style=""color:blue;"">"
		response.write body & "</span>" & vbcrlf & vbcrlf
		response.write string(80,"-") & vbcrlf & "**END OF EMAIL**</pre></body></html>"
	end if
else
	msg.send
	response.redirect redir
end if
set msg = nothing
%>

推荐答案

字段名称


''html-如果其值为"yes",则电子邮件将以html电子邮件的形式发送.仅在提供模板时使用. " testmode-如果将其设置为"yes",则电子邮件内容将被写入屏幕,而不是通过电子邮件发送. ''------------------------------------------------ -------------------------------------------------- -- 昏暗的pde:设置pde = createobject("scripting.dictionary") ''------------------------------------------------ -------------------------------------------------- -- ""mailto"隐藏字段的预定义地址 ''如果您不想在隐藏字段中显示电子邮件地址,请使用标记词并指定 ''在其适用的电子邮件地址下方.例如<输入type ="hidden" name ="mailto" value =%stratdepartment%"> ''此外,您还可以使用%mailfrom%隐藏原始电子邮件地址 pde.add%contactform%","myemail@someaddress.com" pde.add%salesenquiry%","anotheremail@someaddress.com" ''------------------------------------------------ -------------------------------------------------- -- 函数getTextFromFile(path) 昏暗的fso,f,txt 设置fso = createobject("Scripting.FileSystemObject") 如果不是fso.fileexists(path),则 getTextFromFile =" 退出功能 万一 设置f = fso.opentextfile(path,1) 如果f.atendofstream然后txt ="否则txt = f.readall 关闭 设f =无 设置fso =无 getTextFromFile = txt 终端功能 暗淡的redir,mailto,mailfrom,主题,项目,正文,cc,密件抄送,消息,html,模板,usetemplate,testmode redir = request.form(重定向") mailto = request.form("mailto") 如果pde.exists(mailto),则mailto = pde(mailto) 抄送= request.form("cc") 密件抄送= request.form("bcc") mailfrom = request.form("mailfrom") 如果mailfrom =",则mailfrom = pde(%mailfrom%") 主题= request.form(主题") 消息= request.form(消息") 模板= request.form(模板") testmode = lcase(request.form("testmode"))=是" 如果len(template)> 0然后模板= getTextFromFile(server.mappath(template)) 如果len(template)> 0然后usetemplate = true,否则usetemplate = false 昏暗的味精:设置味精= server.createobject("CDO.Message") msg.subject =主题 msg.to = mailto msg.from = mailfrom 如果len(cc)> 0,然后msg.cc = cc 如果len(bcc)> 0,然后msg.bcc = bcc 如果不使用template然后 身体=身体&讯息与vbcrlf& vbcrlf 别的 主体=模板 万一 对于request.form中的每个项目 选择案例项目 大小写重定向","mailto","cc",密件抄送",主题",消息",模板","html",测试模式" 其他情况 如果不使用template,那么 如果项目<> "mailfrom"然后body = body&项& ":& request.form(item)& vbcrlf& vbcrlf 别的 body = replace(body,"
'' html - if this has the value "yes", the email will be sent as an html email. only used if a template is supplied. '' testmode - if this is set to "yes", the email contents will be written to the screen instead of being emailed. ''--------------------------------------------------------------------------------------------------- dim pde : set pde = createobject("scripting.dictionary") ''--------------------------------------------------------------------------------------------------- ''PREDEFINED ADDRESSES for the "mailto" hidden field ''if you don''t want to reveal email addresses in hidden fields, use a token word instead and specify ''below which email address it applies to. e.g. <input type="hidden" name="mailto" value="%stratdepartment%"> ''ALSO, in the same way, you can use %mailfrom% to hide the originating email address pde.add "%contactform%", "myemail@someaddress.com" pde.add "%salesenquiry%", "anotheremail@someaddress.com" ''--------------------------------------------------------------------------------------------------- function getTextFromFile(path) dim fso, f, txt set fso = createobject("Scripting.FileSystemObject") if not fso.fileexists(path) then getTextFromFile = "" exit function end if set f = fso.opentextfile(path,1) if f.atendofstream then txt = "" else txt = f.readall f.close set f = nothing set fso = nothing getTextFromFile = txt end function dim redir, mailto, mailfrom, subject, item, body, cc, bcc, message, html, template, usetemplate, testmode redir = request.form("redirect") mailto = request.form("mailto") if pde.exists(mailto) then mailto = pde(mailto) cc = request.form("cc") bcc = request.form("bcc") mailfrom = request.form("mailfrom") if mailfrom = "" then mailfrom = pde("%mailfrom%") subject = request.form("subject") message = request.form("message") template = request.form("template") testmode = lcase(request.form("testmode"))="yes" if len(template) > 0 then template = getTextFromFile(server.mappath(template)) if len(template) > 0 then usetemplate = true else usetemplate = false dim msg : set msg = server.createobject("CDO.Message") msg.subject = subject msg.to = mailto msg.from = mailfrom if len(cc) > 0 then msg.cc = cc if len(bcc) > 0 then msg.bcc = bcc if not usetemplate then body = body & message & vbcrlf & vbcrlf else body = template end if for each item in request.form select case item case "redirect", "mailto", "cc", "bcc", "subject", "message", "template", "html", "testmode" case else if not usetemplate then if item <> "mailfrom" then body = body & item & ": " & request.form(item) & vbcrlf & vbcrlf else body = replace(body, "


"& item&"
" & item & "


这篇关于CDO.Message.1错误'80040220'配置值无效. msg.send的错误行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆