since you asked, in a nutshell:
You simpy choose the number of your likings. Can be any number as long as it isn't already in use.
Then you use some
Windows APIs to make a (sub)menu item. One of the parameters of those Windows APIs to make a menu is that cmdid.
Now, when you click on a menu the cmdid is
passed (again as a parameter) to the procedure which handles all the events occuring in the window.
Since that cmdid is passed, the routines inside the procedure know what to do next.
Though, all this information is only usefull if you are able to make your own addon (or program) which is capable of integrating itself inside Messenger.
Simply adding your own (sub)menu item, which is easy, isn't going to work. You also need to integrate/replace the routine to catch the menu (and thus the cmdid) being pressed by the user.
More details can be found here:
http://msdn.microsoft.com/en-us/library/ms646977(VS.85).aspx
---
So, making your own custom menu (with your own cmdids) is by far the easiest thing. The hard thing is to inject your program/routine which handles the cmdids into the Messenger program. Usually this is done by
subclassing or superclassing. This is by no means an easy job and requires a lot of programming skills (and a hell of a lot of technical reading and understanding, see the links).
You can't do anything with this information in regards to skinning though. And even with Plus! scripting this is very hard todo (you actually can't do it with pure script code alone).