Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CDO and Error Trapping problem from H***!!!!! 1

Status
Not open for further replies.

PaulinKC

Programmer
Apr 2, 2002
50
US
Ok I am trying to trap a problem with the following code

Public Sub doCDOmail()
on error goto errorhandler
With objcdo

.Configuration = objCDOConfig
.To = strTo
.CC = strCC
.BCC = strBCC
.From = FromAddress
.Subject = strSubject
.HTMLBody = strTxtBody
.AddAttachment (strAttachFile)
.Send

End With

exit sub
errorhandler:

Select Case Err.Number

Case -2147220975
msgbox "You've entered an incorrect parameter for your mail server", vbOKOnly, "Email Server Error"

Case else

msgbox "The following error occurred. Error Number: " & err.number & " Error Description: " & err.description & " Please correct this problem.", vbokonly, "Email Error!"

End Select
Exit Sub
End Sub

When the user enters in an incorrect password or username it gives a runtime error of "-2147220975" The error handler doesn't even work.... am I missing something here??
 
There are a couple of things that I would look at. First of all, I would go to Tools->Options, and on the General Tab, there is a frame for Error Trapping. I would set it to "Break on Unhandled Errors" and see what effect that has on the error handling routine.

I also notice that you're error handling routine does not have a Resume statement. It is not a good idea to leave the Resume out as that statement resets the error handler.

Would like to know how, where, and type of objcdo is declared, in fact, the scope of all of the variables is unclear from the code posted. Also is objCDOConfig an object which upon being assigned to .Configuration requires the use of the Set Command.

Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
 
CajunCenturion - thanks for your help! Changed the Error Trapping to "Break on Unhandled Errors" and it seems to work without any problems!! Thanks a bunch!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top