来自 CDO.Message 发送方法的未知电子邮件代码 [英] Unknown email code from CDO.Message send method
问题描述
我正在尝试通过 vbscript 发送电子邮件.这是我的电子邮件代码:我当然隐藏了电子邮件地址.在我的实际代码中,我使用的是有效的电子邮件地址.
Dim objCDO设置 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") = 25objCDO.Configuration.Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2objCDO.Configuration.Fields("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60objCDO.Configuration.Fields.UpdateobjCDO.To = "abcemail@devnull.com"objCDO.From = 发件人objCDO.cc = ""objCDO.bcc = ""objCDO.Subject = txtSubjectobjCDO.HTMLBody = 替换(sBody, Chr(10),"<br>")错误转到 0出错时继续下一步objCDO.SendIf Err.Number <>0 然后Response.Write "就在发送命令之后"Response.Write "Err.Number is " &Err.Number &<br>"错误转到 0万一设置 objCDO = 无
当此代码运行时,我看到以下错误:
在发送命令之后 Err.Number 是 -2147220978
现在,当我研究这个错误号时,在任何地方都找不到错误代码 -2147220978 的参考.事实上,谷歌搜索数字 -2147220978 根本不会返回任何结果.
你知道那个奇怪的错误代码是什么意思吗?
-2147220978 = 8004020E
来自 CDOSYSERR.h
<代码>////MessageId: CDO_E_SENDER_REJECTED////消息文本:////服务器拒绝发件人地址.服务器响应为: %1//#define CDO_E_SENDER_REJECTED 0x8004020EL
解码错误
-2147220978 样式数字是32位有符号整数,用计算器转换成十六进制.
Windows 错误(小数字)和 COM HResults(通常,但也有例外,以 8 开头,如 0x80040154)在 WinError.h 中定义,除了 8007nnnn,您可以在其中查找它包含的 Window 错误号.
作为一般规则,Windows 错误少于 65,535 (0xFFFF).从 0x80000001 开始的错误是组件对象模型 (COM) HResults.从 0xc0000001 开始的错误是 NTStatus 结果.
NTStatus 错误(通常但不总是以 C 开头,如 0xC0000022)在 NTStatus.h 中定义.
.h 文件是最好的来源,因为它包含错误的符号名称,可以提供诸如错误来源之类的线索.FormatMessage 不给出符号名称,只给出描述.
您可以通过下载 Platform SDK 获得这些文件(以千兆字节为单位)http://www.microsoft.com/en-us/download/details.aspx%3Fid%3D8279&sa=U&ei=w2IrULDDLsHFmAWbmIHoBg&ved=0CBwQFjAA&usg=AFQjCNHZn9-4f2NnuN9o3UWUsOF3wL7HBQp>
如果您只想要这两个文件,我将它们放在我的 skydrive 上,这样我可以随时随地参考它们.https://skydrive.live.com/redir?resid=E2F0CE17A268A4FA!121
注意 Internet 错误 (12,000 - 12,999) 是 Windows 错误,但在 wininet.h 中指定,也可在上面找到.
在其他 .h 文件中定义了错误.但 99% 都在以上三者中.
HResults 和 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
它会说
系统找不到指定的文件.
或在 winerror.h 中查找
<代码>////MessageId: ERROR_FILE_NOT_FOUND////消息文本:////该系统找不到指定的文件.//#define ERROR_FILE_NOT_FOUND 2L
Dos 错误代码(针对 0x8003nnnn 错误)
Dos 错误代码(针对 0x8003nnnn 错误)
代码信息01 无效的功能号02 找不到文件03 找不到路径04 打开的文件太多(没有剩余句柄)05 访问被拒绝06 无效的句柄07 内存控制块被破坏08 内存不足09 无效的内存块地址0A 无效环境0B 格式无效0C 访问模式无效(开放模式无效)0D 无效数据0E 保留0F 指定的驱动器无效10 尝试删除当前目录11 不同设备12 没有更多文件13 尝试在写保护软盘上写入14 未知单位15 驱动器未准备好16 未知命令17 CRC 错误18 错误的请求结构长度19 寻道错误1A 未知媒体类型1B 未找到扇区1C 打印机缺纸一维写错误1E 读取错误1F 一般故障20 共享违规21 锁违规22 无效的磁盘更改23 FCB 不可用24 共享缓冲区溢出25 保留26 无法完成文件操作 (DOS 4.x)27-31 保留32 不支持网络请求33 远程计算机不听34 网络名称重复35 未找到网络名称36 网络繁忙37 网络设备不再存在38 超出 NetBIOS 命令限制39 网络适配器错误3A 网络响应不正确3B 意外的网络错误3C 不兼容的远程适配器3D 打印队列已满3E 打印文件没有空间3F 打印文件已删除40 网络名称已删除41 访问被拒绝42 网络设备类型不正确43 未找到网络名称44 超出网络名称限制45 超出 NetBIOS 会话限制46 暂时停顿47 网络请求不被接受48 打印或磁盘重定向已暂停49-4F 保留50 文件已存在51 保留52 无法进行目录条目53 INT 24 失败54 重定向过多55 重复重定向56 密码无效57 参数无效58 网络设备故障59 网络不支持的功能 (DOS 4.x)5A 未安装所需的系统组件 (DOS 4.x)
设施代码
NTStatus 设施
常用状态值 0x0调试器 0x1RPC_runtime 0x2RPC_stubs 0x3io_error_code 0x4各种驱动0x5-0xfNtwin32 0x7ntsspi 0x9终端服务器 0xaFaciltiy_mui_error_code 0xbUsb_error_code 0x10hid_error_code 0x11Firewire_error_code 0x12Cluster_error_code 0x13Acpi_error_code 0x14Sxs_error_code 0x15事务 0x19通用日志 0x1a视频 0x1b过滤器管理器 0x1c监视器 0x1dGraphics_kernel 0x1eDriver_framework 0x20Fve_error_code 0x21Fwp_error_code 0x22Ndis_error_code 0x23管理程序 0x35ipsec 0x36最大值 0x37
HResults 设施
空 0x0RPC 0x1调度 0x2存储 0x30x4Win32 0x7视窗 0x8SSPI 0x9安全 0x9控制 0xa证书 0xb互联网 0xc媒体服务器 0xdmsmq 0xe设置api 0xf碎片 0x10综合 0x110x12乌尔特 0x13ACS 0x14播放 0x15乌米 0x16SXS 0x17Windows_ce 0x180x19用户模式_commonlog 0x1aUsermode_filter_manager 0x1f背景复制 0x20配置 0x21状态管理 0x22元目录 0x23Windows 更新 0x24目录服务 0x25图形 0x26外壳 0x27Tpm_services 0x28Tpm_software 0x29解放军 0x30Fve 0x31固件 0x32Winrm 0x33Ndis 0x34Usermode_hypervisor 0x35CMMI 0x36Windows_defender 0x50
I'm trying to send an email via vbscript. Here's my email code: I've hidden the email address of course. In my actual code I'm using a valid email address.
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
When this code runs I see the following error:
Just after the send command Err.Number is -2147220978
Now, when I research this error number there is no reference anywhere for error code -2147220978 In fact, a Google search for the number -2147220978 returns no results at all.
Would you have any idea what that odd error code means?
-2147220978 = 8004020E
From 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
Decoding Errors
-2147220978 style numbers are 32 bit signed integers, convert to hex with calculator.
Windows errors (smallish numbers) and COM HResults (typically, but with exceptions, start with an 8 as in 0x80040154) are defined in WinError.h, except 8007nnnn where you look up the Window error number that it contains.
As a general rule Windows errors are less than 65,535 (0xFFFF). Errors starting 0x80000001 are Component Object Model (COM) HResults. Errors starting 0xc0000001 are NTStatus results.
NTStatus errors (typically but not always start with an C as in 0xC0000022) are defined in NTStatus.h.
.h files are the best source because it includes the symbolic name of the error which can give clues such as the source of the error. FormatMessage doesn't give the symbolic name only the description.
You get these files by downloading the Platform SDK (it's gigabytes) http://www.microsoft.com/en-us/download/details.aspx%3Fid%3D8279&sa=U&ei=w2IrULDDLsHFmAWbmIHoBg&ved=0CBwQFjAA&usg=AFQjCNHZn9-4f2NnuN9o3UWUsOF3wL7HBQ
If you just want the two files I have them on my skydrive so I can reference them anywhere I go. https://skydrive.live.com/redir?resid=E2F0CE17A268A4FA!121
Note internet errors (12,000 - 12,999) are windows errors but are specified in wininet.h also available above.
There are errors defined in other .h files. But 99% are in the three above.
Structure of HResults and NTStatus Codes
The most significant bit in HResults, and the two most significant bits in NTStatus are set on error. Hence Hresults start 8 on error and NTStatus starts C on Error. The next 14 or 15 bits are reserved and some specify the facility - what area the error is in. This is the third and fourth number when reading hex. EG 0xnn07nnnn - An HResult facility code 7 is a normal Windows' error (returned from a COM program - hence it's returned as a HResult). Facility codes are defined in Winerror.h for HResults and NTStatus.h for NTStatus codes. They are different.
To Decode 0x8003nnnn Errors
HResults with facility code 3 means the HResult contains OLE Structured Storage errors (0x0 to 0xff). These don't seem to be in Windows' header files and the list of codes is at the end of this post.
To Decode 0x8004nnnn Errors
HResults with facility code 4 means the HResult contains OLE errors (0x0 to 0x1ff) while the rest of the range (0x200 onwards) is component specific errors so 20e from one component will have a different meaning to 20e from another component.
This is why the source of the error is extra important for errors above 0x80040200.
To Decode 0x8007nnnn Errors
HResults with facility code 7 means the HResult contains a Windows' error code. You have to look up the Windows' error code not the HResult.
To decode 0x80070002. The 0x means it's a hexadecimal number, the 8 means error, the first 7 means it a windows error, and the rest of the number, 2, is the actual Windows error.
To look up the error we need it in decimal format. Start Calculator (Start - All Programs - Accessories - Calculator) and choose View menu - Scientific, then View menu - Hex. Enter 2. Then View menu - Decimal. It will say 2.
Start a Command Prompt (Start - All Programs - Accessories - Command Prompt) and type
net helpmsg 2
and it will say
The system cannot find the file specified.
or look it up in winerror.h
//
// MessageId: ERROR_FILE_NOT_FOUND
//
// MessageText:
//
// The system cannot find the file specified.
//
#define ERROR_FILE_NOT_FOUND 2L
Dos Error Codes (for 0x8003nnnn errors)
Dos Error Codes (for 0x8003nnnn errors)
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)
Facility Codes
NTStatus Facilities
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 Facilities
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
这篇关于来自 CDO.Message 发送方法的未知电子邮件代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!