我想使用下面的代码在电子邮件中发送html表格。它适用于小型html表。发送大型html表时,会抛出错误。
“邮件无法发送到SMTP服务器。传输错误代码为0x800ccc63。服务器响应为501语法错误 - 行太长”
如何使用vbscript发送大型html表格内容?
Set objMessage = CreateObject("CDO.Message")
objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True
objMessage.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
objMessage.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp server name"
objMessage.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 465
objMessage.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
objMessage.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusername") = "email address"
objMessage.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "password"
objMessage.Configuration.Fields.Update
objMessage.Subject = "subject"
objMessage.From = "from email"
objMessage.To = "to email"
objMessage.HTMLBody = "html body that contains large table"
objMessage.Send
If Err Then
rtmsg = "ERROR " & Err.Number & ": " & Err.Description
Err.Clear()
Else
rtmsg = "Message sent"
End If
MsgBox(rtmsg)
答案 0 :(得分:1)
如果您有太多没有换行符或空格的连续字符,就会发生这种情况。有些邮件服务器拒绝包含垃圾邮件等内容的邮件(这不完全是关于vbscript的,但解释了会发生什么):
某些电子邮件系统使用未经请求的商业电子邮件(UCE)过滤器 可以配置为拒绝具有多个的电子邮件活动 电子邮件正文中有999个连续字符。一个(...) 电子邮件活动可能会被UCE过滤器拒绝 收件人的组织,如果满足以下任一条件 真:
•邮件正文包含超过999个连续字符。
•邮件中不包含换行符或回车符。
注意:未经请求的商业电子邮件也称为垃圾邮件。
(http://support.microsoft.com/kb/896997/en-us)
尝试添加空格或新行。 在构建html表时,尝试在< / tr>之后添加vbcrlf(换行)。或< / td>例如。