[英]Unknown email code from CDO.Message send method
我正在尝试通过vbscript发送电子邮件。 这是我的电子邮件代码:我当然已经隐藏了电子邮件地址。 在我的实际代码中,我使用的是有效的电子邮件地址。
Dim objCDO
Set objCDO = Server.CreateObject("CDO.Message")
objCDO.Configuration.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.oa.caiso.com"
objCDO.Configuration.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
objCDO.Configuration.Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
objCDO.Configuration.Fields("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
objCDO.Configuration.Fields.Update
objCDO.To = "abcemail@devnull.com"
objCDO.From = Sender
objCDO.cc = ""
objCDO.bcc = ""
objCDO.Subject = txtSubject
objCDO.HTMLBody = Replace(sBody, Chr(10),"<br>")
On Error GoTo 0
On Error Resume Next
objCDO.Send
If Err.Number <> 0 Then
Response.Write "Just after the send command "
Response.Write "Err.Number is " & Err.Number & "<br>"
On Error GoTo 0
End If
set objCDO = nothing
运行此代码时,我看到以下错误:
在发送命令Err.Number之后是-2147220978
现在,当我研究此错误号时,错误代码-2147220978到处都没有引用。实际上,对于编号-2147220978的Google搜索根本没有返回任何结果。
您知道那个奇怪的错误代码是什么意思吗?
-2147220978 = 8004020E
从CDOSYSERR.h
//
// MessageId: CDO_E_SENDER_REJECTED
//
// MessageText:
//
// The server rejected the sender address. The server response was: %1
//
#define CDO_E_SENDER_REJECTED 0x8004020EL
解码错误
-2147220978样式编号是32位有符号整数,可通过计算器转换为十六进制。
Windows错误(较小的数字)和COM HResults(通常,但有例外,以0x80040154中的8开头)在WinError.h中定义,除了8007nnnn,在其中查找它包含的Window错误号。
通常,Windows错误小于65,535(0xFFFF)。 从0x80000001开始的错误是组件对象模型(COM)HResults。 以0xc0000001开头的错误是NTStatus结果。
NTStatus.h中定义了NTStatus错误(通常但并非总是以0xC0000022开头的C开头)。
.h文件是最好的来源,因为它包含错误的符号名,它可以提供诸如错误源之类的线索。 FormatMessage不仅给出符号名称的描述。
您可以通过下载Platform SDK(千兆字节) http://www.microsoft.com/zh-cn/download/details.aspx%3Fid%3D8279&sa=U&ei=w2IrULDDLsHFmAWbmIHoBg&ved=0CBwQFjAA&usg=AFQJCNHZn9-4f2N
如果您只想要这两个文件,我会将它们放在skydrive上,这样我就可以在任何地方引用它们。 https://skydrive.live.com/redir?resid=E2F0CE17A268A4FA!121
注意Internet错误(12,000-12,999)是Windows错误,但在以上的wininet.h中已指定。
在其他.h文件中定义了错误。 但以上三者中有99%。
HResult和NTStatus代码的结构
HResults中的最高有效位以及NTStatus中的两个最高有效位被设置为错误。 因此,Hresults在错误时以8开始,而NTStatus在错误时以C开始。 接下来的14或15位将被保留,其中一些会指定功能-错误所在的区域。这是读取十六进制时的第三个和第四个数字。 EG 0xnn07nnnn-HResult工具代码7是Windows的正常错误(从COM程序返回-因此它作为HResult返回)。 功能代码在Winerror.h中定义为HResults,在NTStatus.h中定义为NTStatus代码。 他们是不同的。
解码0x8003nnnn错误
具有设施代码3的HResults表示HResult包含OLE结构化存储错误(0x0至0xff)。 这些似乎不在Windows的头文件中,并且代码列表在本文的结尾。
解码0x8004nnnn错误
具有设施代码4的HResults表示HResult包含OLE错误(0x0至0x1ff),而其余范围(0x200起)是特定于组件的错误,因此一个组件中的20e与另一个组件中的20e具有不同的含义。
这就是为什么对于0x80040200以上的错误,错误的来源特别重要的原因。
解码0x8007nnnn错误
具有功能代码7的HResults表示HResult包含Windows的错误代码。 您必须查找Windows的错误代码而不是HResult。
解码0x80070002。 0x表示它是一个十六进制数,8表示错误,前7表示它是Windows错误,数字的其余部分2是实际的Windows错误。
要查找错误,我们需要十进制格式。 启动计算器(开始-所有程序-附件-计算器),然后选择查看菜单-科学,然后选择查看菜单-十六进制。 输入2。然后单击“查看”菜单-“十进制”。 它会说2。
启动命令提示符(开始-所有程序-附件-命令提示符)并键入
net helpmsg 2
它会说
The system cannot find the file specified.
或在winerror.h中查找
//
// MessageId: ERROR_FILE_NOT_FOUND
//
// MessageText:
//
// The system cannot find the file specified.
//
#define ERROR_FILE_NOT_FOUND 2L
Dos错误代码(用于0x8003nnnn错误)
Dos错误代码(用于0x8003nnnn错误)
Code Message
01 Invalid function number
02 File not found
03 Path not found
04 Too many open files (no handles left)
05 Access denied
06 Invalid handle
07 Memory control blocks destroyed
08 Insufficient memory
09 Invalid memory block address
0A Invalid environment
0B Invalid format
0C Invalid access mode (open mode is invalid)
0D Invalid data
0E Reserved
0F Invalid drive specified
10 Attempt to remove current directory
11 Not same device
12 No more files
13 Attempt to write on a write-protected diskette
14 Unknown unit
15 Drive not ready
16 Unknown command
17 CRC error
18 Bad request structure length
19 Seek error
1A Unknown media type
1B Sector not found
1C Printer out of paper
1D Write fault
1E Read fault
1F General failure
20 Sharing violation
21 Lock violation
22 Invalid disk change
23 FCB unavailable
24 Sharing buffer overflow
25 Reserved
26 Unable to complete file operation (DOS 4.x)
27-31 Reserved
32 Network request not supported
33 Remote computer not listening
34 Duplicate name on network
35 Network name not found
36 Network busy
37 Network device no longer exists
38 NetBIOS command limit exceeded
39 Network adapter error
3A Incorrect network response
3B Unexpected network error
3C Incompatible remote adapter
3D Print queue full
3E No space for print file
3F Print file deleted
40 Network name deleted
41 Access denied
42 Network device type incorrect
43 Network name not found
44 Network name limit exceeded
45 NetBIOS session limit exceeded
46 Temporarily paused
47 Network request not accepted
48 Print or disk redirection is paused
49-4F Reserved
50 File already exists
51 Reserved
52 Cannot make directory entry
53 Fail on INT 24
54 Too many redirections
55 Duplicate redirection
56 Invalid password
57 Invalid parameter
58 Network device fault
59 Function not supported by network (DOS 4.x)
5A Required system component not installed (DOS 4.x)
设施代码
NTStatus设施
Common status values 0x0
Debugger 0x1
Rpc_runtime 0x2
Rpc_stubs 0x3
Io_error_code 0x4
Various drivers 0x5-0xf
Ntwin32 0x7
Ntsspi 0x9
Terminal_server 0xa
Faciltiy_mui_error_code 0xb
Usb_error_code 0x10
Hid_error_code 0x11
Firewire_error_code 0x12
Cluster_error_code 0x13
Acpi_error_code 0x14
Sxs_error_code 0x15
Transaction 0x19
Commonlog 0x1a
Video 0x1b
Filter_manager 0x1c
Monitor 0x1d
Graphics_kernel 0x1e
Driver_framework 0x20
Fve_error_code 0x21
Fwp_error_code 0x22
Ndis_error_code 0x23
Hypervisor 0x35
Ipsec 0x36
Maximum_value 0x37
HResults设施
Null 0x0
Rpc 0x1
Dispatch 0x2
Storage 0x3
Itf 0x4
Win32 0x7
Windows 0x8
Sspi 0x9
Security 0x9
Control 0xa
Cert 0xb
Internet 0xc
Mediaserver 0xd
Msmq 0xe
Setupapi 0xf
Scard 0x10
Complus 0x11
Aaf 0x12
Urt 0x13
Acs 0x14
Dplay 0x15
Umi 0x16
Sxs 0x17
Windows_ce 0x18
Http 0x19
Usermode_commonlog 0x1a
Usermode_filter_manager 0x1f
Backgroundcopy 0x20
Configuration 0x21
State_management 0x22
Metadirectory 0x23
Windowsupdate 0x24
Directoryservice 0x25
Graphics 0x26
Shell 0x27
Tpm_services 0x28
Tpm_software 0x29
Pla 0x30
Fve 0x31
Fwp 0x32
Winrm 0x33
Ndis 0x34
Usermode_hypervisor 0x35
Cmi 0x36
Windows_defender 0x50
这是帮助页面。
Exchange Server 2003
错误代码发送反馈
::::::::
Windows 2000的CDO>参考>
(宣言)
错误代码本节包含Windows 2000的Microsoft CDO使用的自定义错误代码。所有这些值都可以在类型库CdoErrorCodes模块中用作常量。
错误值是32位值,其结构如下所示:
复印代码3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 8 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 + --- +-+-+ --------------------------- + ----------- -------------------- + | Sev | C | R | 设施| 代码 + --- +-+-+ ----------------------- + ----------------- -------------- +
从左到右读取此描述,严重性代码Sev是以下值之一:
00-成功
01-信息性
10-警告
11-错误
其次是:
C —客户代码标志。
R —保留位。
便利性-便利性代码。
代码-设施的状态码。
错误名称值备注
CDO_E_UNCAUGHT_EXCEPTION 0x80040201L异常%1在地址%2处生成
CDO_E_NOT_OPENED 0x80040202L尚未为该对象打开任何数据源。
CDO_E_UNSUPPORTED_DATASOURCE 0x80040203L对象不支持这种类型的数据源。
CDO_E_INVALID_PROPERTYNAME 0x80040204L该对象不支持所请求的属性名称或名称空间。
CDO_E_PROP_UNSUPPORTED 0x80040205L该对象不支持所请求的属性。
CDO_E_INACTIVE 0x80040206L该对象无效。 它可能已被删除或尚未打开。
CDO_E_NO_SUPPORT_FOR_OBJECTS 0x80040207L对象不支持存储对象的持久状态信息。
CDO_E_NOT_AVAILABLE 0x80040208L虽然支持请求的属性或功能,但当前或在此上下文中不可用。
CDO_E_NO_DEFAULT_DROP_DIR 0x80040209L尚未为此服务器配置默认放置目录。
CDO_E_SMTP_SERVER_REQUIRED 0x8004020AL SMTP服务器名称是必需的,在配置源中找不到。
CDO_E_NNTP_SERVER_REQUIRED 0x8004020BL NNTP服务器名称是必需的,并且在配置源中找不到。
CDO_E_RECIPIENT_MISSING 0x8004020CL至少需要一个收件人,但找不到任何收件人。
CDO_E_FROM_MISSING 0x8004020DL至少需要“发件人”或“发件人”字段之一,但均未找到。
CDO_E_SENDER_REJECTED 0x8004020EL服务器拒绝了发件人地址。 服务器响应为:%1
CDO_E_RECIPIENTS_REJECTED 0x8004020FL服务器拒绝了一个或多个收件人地址。 服务器响应为:%1
CDO_E_NNTP_POST_FAILED 0x80040210L无法将消息发布到NNTP服务器。 传输错误代码为%2。 服务器响应为%1
CDO_E_SMTP_SEND_FAILED 0x80040211L无法将邮件发送到SMTP服务器。 传输错误代码为%2。 服务器响应为%1
CDO_E_CONNECTION_DROPPED 0x80040212L传输断开了与服务器的连接。
CDO_E_FAILED_TO_CONNECT 0x80040213L传输无法连接到服务器。
CDO_E_INVALID_POST 0x80040214L主题,发件人和新闻组字段均为必填字段,但未找到一个或多个字段。
CDO_E_AUTHENTICATION_FAILURE 0x80040215L由于身份验证失败,服务器拒绝了登录尝试。 服务器响应为:%1
CDO_E_INVALID_CONTENT_TYPE 0x80040216L在此上下文中,内容类型无效。 例如,MHTML消息的根必须是HTML文档。
CDO_E_LOGON_FAILURE 0x80040217L传输无法登录到服务器。
CDO_E_HTTP_NOT_FOUND 0x80040218L找不到请求的资源。 服务器响应为:%1。
CDO_E_HTTP_FORBIDDEN 0x80040219L拒绝访问所请求的资源。 服务器响应为:%1。
CDO_E_HTTP_FAILED 0x8004021AL HTTP请求失败。 服务器响应为:%1。
CDO_E_MULTIPART_NO_DATA 0x8004021BL这是一个多部分身体部位。 除了其中包含的身体部位之外,它没有其他内容。
CDO_E_INVALID_ENCODING_FOR_MULTIPART 0x8004021CL多部分主体部分必须编码为7位,8位或二进制。
CDO_E_PROP_NOT_FOUND 0x8004021EL找不到请求的属性。
CDO_E_INVALID_SEND_OPTION 0x80040220L“ SendUsing”配置值无效。
CDO_E_INVALID_POST_OPTION 0x80040221L“使用后”配置值无效。
CDO_E_NO_PICKUP_DIR 0x80040222L拾取目录路径是必需的,未指定。
CDO_E_NOT_ALL_DELETED 0x80040223L无法删除一个或多个消息。
CDO_E_PROP_READONLY 0x80040227L该属性是只读的。
CDO_E_PROP_CANNOT_DELETE 0x80040228L无法删除该属性。
CDO_E_BAD_DATA 0x80040229L写入对象的数据不一致或无效。
CDO_E_PROP_NONHEADER 0x8004022AL所请求的属性不在邮件头名称空间中。
CDO_E_INVALID_CHARSET 0x8004022BL所请求的字符集未安装在计算机上。
CDO_E_ADOSTREAM_NOT_BOUND 0x8004022CL尚未打开ADO流。
CDO_E_CONTENTPROPXML_NOT_FOUND 0x8004022DL缺少内容属性。
CDO_E_CONTENTPROPXML_WRONG_CHARSET 0x8004022EL内容属性XML必须使用UTF-8进行编码。
CDO_E_CONTENTPROPXML_PARSE_FAILED 0x8004022FL无法解析内容属性XML。
CDO_E_CONTENTPROPXML_CONVERT_FAILED 0x80040230L无法将属性从XML转换为请求的类型。
CDO_E_NO_DIRECTORIES_SPECIFIED 0x80040231L没有指定用于解析的目录。
CDO_E_DIRECTORIES_UNREACHABLE 0x80040232L无法针对一个或多个指定目录进行解析。
CDO_E_BAD_SENDER 0x80040233L找不到发件人的邮箱。
CDO_E_SELF_BINDING 0x80040234L不允许绑定到自身。
CDO_E_ARGUMENT1 0x80044000L第一个参数无效。
CDO_E_ARGUMENT2 0x80044001L第二个参数无效。
CDO_E_ARGUMENT3 0x80044002L第三个参数无效。
CDO_E_ARGUMENT4 0x80044003L第四个参数无效。
CDO_E_ARGUMENT5 0x80044004L第五个参数无效。
CDO_E_NOT_FOUND 0x800CCE05L在此消息中找不到所请求的正文部分。
CDO_E_INVALID_ENCODING_TYPE 0x800CCE1DL内容编码类型无效。
文档反馈Microsoft重视您的反馈。 要对该主题进行评分并将有关此主题的反馈发送给文档团队,请单击评分,然后单击“发送反馈”。 有关支持问题的帮助,请参阅产品随附的技术支持信息。 较差1 2 3 4 5优秀要通过电子邮件将您的反馈发送给Microsoft,请单击此处:
©2005 Microsoft Corporation。 版权所有。
您很可能需要针对您的邮件服务器进行身份验证。 您可以通过添加以下行来使用CDOSYS进行此操作。 您当然需要将sendusername和sendpassword值更改为有效帐户。
objCDO.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1 'basic (clear-text) authentication
objCDO.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusername") ="somemail@yourserver.com"
objCDO.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword") ="yourpassword"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.