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
Here's a page from Help.
Exchange Server 2003
Error Codes Send Feedback
: : : : : : :
CDO for Windows 2000 > Reference >
(Declaration)
Error Codes This section contains the custom error codes used by Microsoft CDO for Windows 2000. All of these values are available as constants in the type library CdoErrorCodes module.
Error values are 32 bit values whose structure is depicted here:
Copy Code 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 1 0 9 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| Facility | Code | +---+-+-+-----------------------+-------------------------------+
Reading this depiction from left-to-right, the severity code, Sev, is one of the following values:
00 - Success
01 - Informational
10 - Warning
11 - Error
Followed by:
C — The customer code flag.
R — A reserved bit.
Facitlity — The facility code.
Code — The facilitiy's status code.
Error Name Value Remarks
CDO_E_UNCAUGHT_EXCEPTION
0x80040201L
Exception %1 was generated at address %2
CDO_E_NOT_OPENED 0x80040202L No data source has been opened for the object.
CDO_E_UNSUPPORTED_DATASOURCE 0x80040203L The object does not support this type of data source.
CDO_E_INVALID_PROPERTYNAME 0x80040204L The object does not support the requested property name or namespace.
CDO_E_PROP_UNSUPPORTED 0x80040205L The object does not support the requested property.
CDO_E_INACTIVE 0x80040206L The object is not active. It may have been deleted or it may not have been opened.
CDO_E_NO_SUPPORT_FOR_OBJECTS 0x80040207L The object does not support storing persistent state information for objects.
CDO_E_NOT_AVAILABLE 0x80040208L The requested property or feature, while supported, is not available at this time or in this context.
CDO_E_NO_DEFAULT_DROP_DIR 0x80040209L No default drop directory has been configured for this server.
CDO_E_SMTP_SERVER_REQUIRED 0x8004020AL The SMTP server name is required, and was not found in the configuration source.
CDO_E_NNTP_SERVER_REQUIRED 0x8004020BL The NNTP server name is required, and was not found in the configuration source.
CDO_E_RECIPIENT_MISSING 0x8004020CL At least one recipient is required, but none were found.
CDO_E_FROM_MISSING 0x8004020DL At least one of the From or Sender fields is required, and neither was found.
CDO_E_SENDER_REJECTED 0x8004020EL The server rejected the sender address. The server response was: %1
CDO_E_RECIPIENTS_REJECTED 0x8004020FL The server rejected one or more recipient addresses. The server response was: %1
CDO_E_NNTP_POST_FAILED 0x80040210L The message could not be posted to the NNTP server. The transport error code was %2. The server response was %1
CDO_E_SMTP_SEND_FAILED 0x80040211L The message could not be sent to the SMTP server. The transport error code was %2. The server response was %1
CDO_E_CONNECTION_DROPPED 0x80040212L The transport lost its connection to the server.
CDO_E_FAILED_TO_CONNECT 0x80040213L The transport failed to connect to the server.
CDO_E_INVALID_POST 0x80040214L The Subject, From, and Newsgroup fields are all required, and one or more was not found.
CDO_E_AUTHENTICATION_FAILURE 0x80040215L The server rejected the logon attempt due to authentication failure. The server response was: %1
CDO_E_INVALID_CONTENT_TYPE 0x80040216L The content type was not valid in this context. For exmaple, the root of an MHTML message must be an HTML document.
CDO_E_LOGON_FAILURE 0x80040217L The transport was unable to log on to the server.
CDO_E_HTTP_NOT_FOUND 0x80040218L The requested resource could not be found. The server response was: %1.
CDO_E_HTTP_FORBIDDEN 0x80040219L Access to the requested resource is denied. The server response was: %1.
CDO_E_HTTP_FAILED 0x8004021AL The HTTP request failed. The server response was: %1.
CDO_E_MULTIPART_NO_DATA 0x8004021BL This is a multipart body part. It has no content other than the body parts contained within it.
CDO_E_INVALID_ENCODING_FOR_MULTIPART 0x8004021CL Multipart body parts must be encoded as 7bit, 8bit, or binary.
CDO_E_PROP_NOT_FOUND 0x8004021EL The requested property was not found.
CDO_E_INVALID_SEND_OPTION 0x80040220L The "SendUsing" configuration value is invalid.
CDO_E_INVALID_POST_OPTION 0x80040221L The "PostUsing" configuration value is invalid.
CDO_E_NO_PICKUP_DIR 0x80040222L The pickup directory path is required and was not specified.
CDO_E_NOT_ALL_DELETED 0x80040223L One or more messages could not be deleted.
CDO_E_PROP_READONLY 0x80040227L The property is read-only.
CDO_E_PROP_CANNOT_DELETE 0x80040228L The property cannot be deleted.
CDO_E_BAD_DATA 0x80040229L Data written to the object are inconsistent or invalid.
CDO_E_PROP_NONHEADER 0x8004022AL The requested property is not in the mail header namespace.
CDO_E_INVALID_CHARSET 0x8004022BL The requested character set is not installed on the computer.
CDO_E_ADOSTREAM_NOT_BOUND 0x8004022CL The ADO stream has not been opened.
CDO_E_CONTENTPROPXML_NOT_FOUND 0x8004022DL The content properties are missing.
CDO_E_CONTENTPROPXML_WRONG_CHARSET 0x8004022EL Content properties XML must be encoded using UTF-8.
CDO_E_CONTENTPROPXML_PARSE_FAILED 0x8004022FL Failed to parse content properties XML.
CDO_E_CONTENTPROPXML_CONVERT_FAILED 0x80040230L Failed to convert a property from XML to a requested type.
CDO_E_NO_DIRECTORIES_SPECIFIED 0x80040231L No directories were specified for resolution.
CDO_E_DIRECTORIES_UNREACHABLE 0x80040232L Failed to resolve against one or more of the specified directories.
CDO_E_BAD_SENDER 0x80040233L Could not find the Sender's mailbox.
CDO_E_SELF_BINDING 0x80040234L Binding to self is not allowed.
CDO_E_ARGUMENT1 0x80044000L The first argument is invalid.
CDO_E_ARGUMENT2 0x80044001L The second argument is invalid.
CDO_E_ARGUMENT3 0x80044002L The third argument is invalid.
CDO_E_ARGUMENT4 0x80044003L The fourth argument is invalid.
CDO_E_ARGUMENT5 0x80044004L The fifth argument is invalid.
CDO_E_NOT_FOUND 0x800CCE05L The requested body part was not found in this message.
CDO_E_INVALID_ENCODING_TYPE 0x800CCE1DL The content encoding type is invalid.
Documentation Feedback
Microsoft values your feedback. To rate this topic and send feedback about this topic to the documentation team, click a rating, and then click Send Feedback. For assistance with support issues, refer to the technical support information included with the product.
Poor 1
2
3
4
5
Outstanding
To e-mail your feedback to Microsoft, click here:
© 2005 Microsoft Corporation. All rights reserved.
You most likely need to authenticate against your mail server. You can do this with CDOSYS by adding the following lines. You will of course need to change the sendusername and sendpassword values to a valid account.
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"
来源:https://stackoverflow.com/questions/24317238/unknown-email-code-from-cdo-message-send-method