I have a script were an email has to be sent. The email comes from the user and is not properly checked. So I have discovered that when the email is sent the following error occurs "CDO.Message.1: The "SendUsing" configuration value is invalid." and it is displayed as a message box.
In order to avoid this I thought that I could use "on error resume next" but it seems that it does not work, because after the send command the Err object is 0. I tried also the Err.Number and its also 0
The script runs automatically in the background so an error message is not acceptable but also just placing "on error resume next" without knowing that an error occurred is still not acceptable.
Is there a way of knowing that the CDO.Message.Send has failed but without presenting a dialog box.
It seems that some people did not understood my problem. Here is an example
Set EMail = CreateObject("CDO.Message")
EMail.Subject = "Just for test"
EMail.HTMLBody = "..."
' this comes from another place
EMail.TO = "49 (9132) 82-72 9743@xxx"
EMail.CC = ""
EMail.BCC = ""
With EMail.Configuration.Fields
.Item(Schema & "sendusing") = 2
.Item(Schema & "smtpserver") = "..."
.Item(Schema & "smtpserverport") = 25
.Update
End With
on error resume next
EMail.Send
' this line prints The error was 0 even though the email is not valid and the Send was not successfull
WScript.Echo "The error was " & Err.Number
If you comment the on error resume next you get the error displayed "CDO.Message.1: The "SendUsing" configuration value is invalid."