Codestone Ltd logo

Search FAQ


Internet Mail Client Control FAQs/Errors

How do I trap errors in Visual C++?

ID: S12E14 DATE: N/A

The CSMail library uses the standard OLE Automation error mechanism and you should be prepared to handle these errors as you would other run-time errors in your application. How you trap these errors depends on how you call the library in your application.

Trapping errors in the standard methods of the wrapper classes generated by the #import directive

The standard methods of the wrapper classes will throw a _com_error exception when an error occurs. The HRESULT value in the .error member of the _com_error class corresponds to the error numbers listed in the manual. See the article "Microsoft Visual C++ 5.0 Compiler Native COM Support" in the Microsoft Platform SDK for more information on #import and the wrapper classes.

Trapping errors in the raw methods of the wrapper classes generated by the #import directive

The raw methods of the wrapper classes return an HRESULT which corresponds to the error numbers listed in the manual. See the article "Microsoft Visual C++ 5.0 Compiler Native COM Support" in the Microsoft Platform SDK for more information on #import and the wrapper classes.

Trapping errors in methods called directly through interfaces

Object methods called directly through an interface pointer return an HRESULT which corresponds to the error numbers listed in the manual.

Errors raised by the Internet Mail Client Control Library will usually be the result of unexpected network or server conditions. Such errors do not imply an error in your code or in the library but simply an unexpected condition that needs to be trapped and processed in your error handler.

Appendix B of the manual lists the errors that the library may raise together with some notes on how you might handle them. You will also find some notes on specific errors in this section of the FAQ.


Can't find the answer to your question? We're here to help!