Ordering Function Calls to Ensure Table Notifications
Microsoft Exchange Server automatically batches calls to the IMAPITable::SetColumns and IMAPITable::SortTable methods, even if not expressly requested to do so by the calling application. Because of this batching, you need to make these calls in a certain order to receive notifications. Specifically, IMAPITable::GetRowCount or IMAPITable::QueryRows must be called before changes are made to a table for which notifications are expected.
For example, your code may contain a sequence like the following:
-
Call lpFolder–>GetContentsTable(lpTable)
-
Call lpTable–>Advise
-
Call methods on objects other than the table, such as lpFolder–>CreateMessage, SetProps, and then SaveChanges on the messages. It is these calls that cause the changes for which notifications are expected.
The result of this sequence is that notifications do not arrive. However, notifications are received if the following order is followed, in which GetRowCount is called before changes are made to the table:
-
Call lpFolder–>GetContentsTable(lpTable)
-
Call lpTable–>Advise
-
Call lpTable–>GetRowCount or lpTable–>QueryRows. Calling this method at this point enables notifications for the changes to be made in the next step.
-
Call methods on objects other than the table, such as lpFolder–>CreateMessage, SetProps, and then SaveChanges on the messages. It is these calls that cause the changes for which notifications are expected.