How can I allocate reference numbers to all messages so they can be indexed for future search and retrieval?