This documentation is archived and is not being maintained.


This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This page may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.

Returns the total number of rows in the table.

HRESULT GetRowCount(
ULONG ulFlags,
ULONG FAR * lpulCount


Reserved; must be zero.


[out] Pointer to the number of rows in the table.


The row count was successfully returned.


Another operation is in progress that prevents the row count retrieval operation from starting. Either the operation in progress should be allowed to complete or it should be stopped.


The table cannot calculate the number of rows.


The call succeeded, but an approximate row count was returned because the exact row count could not be determined possibly due to memory constraints. To test for this warning, use the HR_FAILED macro. See Using Macros for Error Handling.

The IMAPITable::GetRowCount method retrieves the total number of rows in a table.

If you cannot determine the table's exact row count, return MAPI_W_APPROX_COUNT and an approximate row count in the contents of the lpulCount parameter.

Use GetRowCount to find out how many rows a table holds before making a call to the IMAPITable::QueryRows method to retrieve the data. If there are less than twenty rows in the table, it is safe to call QueryPosition to retrieve the whole table. If there are more than twenty rows in the table, consider making multiple calls to QueryPosition and limit the number of rows retrieved in each call.

Some tables do not support GetRowCount and return MAPI_E_NO_SUPPORT. If GetRowCount is not supported, an alternative might be to call IMAPITable::QueryPosition. With the results from QueryPosition, you can determine the relationship between the current row and last row.

When GetRowCount returns MAPI_E_BUSY because it is temporarily unable to retrieve a row count, call the IMAPITable::WaitForCompletion method. When WaitForCompletion returns, retry the call to GetRowCount. Another way to detect whether an asynchronous operation is in progress is to call the IMAPITable::GetStatus method and check the contents of the lpulTableState parameter.

For MFCMAPI sample code, see the following table.






MFCMAPI uses the IMAPITable::GetRowCount method to determine how many rows are in the source table so memory can be allocated to perform the copy.