Because MAPI and Microsoft Exchange Server service providers implement strict parameter checking, they often return the MAPI_E_INVALID_PARAMETER error code, which can help with debugging. You can use this mechanism to make sure the parameters you are passing are valid. Parameters are checked first, within the call, and the parameters of nested structures are checked at the same time. This and similar error codes can help you determine whether the object you are passing contains valid properties and parameters.
MAPI_E_INVALID_PARAMETER does not always pinpoint errors, especially when your code deals with MAPI objects that contain other objects. This is a general error return that can apply to many sub-objects of a complicated object, such as a message. For example, this error may imply that parameters are invalid, or that properly constructed structures were allocated incorrectly, such as when an incorrect allocator function has been used. For more information, see the MAPI Programmer's Reference.
Based on the information returned to you with this error code, you can devise a strategy for finding and fixing the error. One possibility is to use the message store viewer to inspect the objects involved. This tool provides a representation of any object in the information store, shown in a way that accurately depicts its programmatic elements. It may help you find and fix a problem with an incorrect object parameter.