使用 VBScript 发送电子邮件
Send Email Using VBScript
我想使用下面的代码在电子邮件中发送 html table。它与 smalls html tables 一起正常工作。发送大 html table 时,会抛出错误。
"The message could not be sent to the SMTP server. The transport error code was 0x800ccc63. The server response was 501 Syntax error - line too long"
如何使用 vbscript 发送大 html table 内容?
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)
如果没有换行符或空格的连续字符太多,就会发生这种情况。一些邮件服务器拒绝包含垃圾邮件等内容的邮件(这不完全是关于 vbscript,但解释了会发生什么):
Some e-mail systems use an unsolicited commercial e-mail (UCE) filter
that may be configured to reject e-mail activities that have more than
999 consecutive characters in the body of the e-mail message. An (...)
e-mail activity may be rejected by the UCE filter in the
recipient's organization if either of the following conditions is
true:
•The message body contains more than 999 consecutive characters.
•The message contains no line feeds or carriage returns.
Note: Unsolicited commercial e-mail is also known as spam.
(http://support.microsoft.com/kb/896997/en-us)
尝试添加空格或新行。
例如,在构建 html table 时,尝试在 或 之后添加一个 vbcrlf(新行)。
我想使用下面的代码在电子邮件中发送 html table。它与 smalls html tables 一起正常工作。发送大 html table 时,会抛出错误。
"The message could not be sent to the SMTP server. The transport error code was 0x800ccc63. The server response was 501 Syntax error - line too long"
如何使用 vbscript 发送大 html table 内容?
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)
如果没有换行符或空格的连续字符太多,就会发生这种情况。一些邮件服务器拒绝包含垃圾邮件等内容的邮件(这不完全是关于 vbscript,但解释了会发生什么):
Some e-mail systems use an unsolicited commercial e-mail (UCE) filter that may be configured to reject e-mail activities that have more than 999 consecutive characters in the body of the e-mail message. An (...) e-mail activity may be rejected by the UCE filter in the recipient's organization if either of the following conditions is true:
•The message body contains more than 999 consecutive characters.
•The message contains no line feeds or carriage returns.
Note: Unsolicited commercial e-mail is also known as spam.
(http://support.microsoft.com/kb/896997/en-us)
尝试添加空格或新行。 例如,在构建 html table 时,尝试在 或 之后添加一个 vbcrlf(新行)。