The midiinfo object can report on currently available MIDI inputs and outputs, outputting this information in a format that can be stored as items in a umenu object.
Look at the example patcher midiinfoLoadbang.maxpat.
A bang into the left inlet of midiinfo sends out midi outputs. Check the print window to see that it sends the message clear (erasing the contents of the umenu object), then append <output name>, append <output name>, etc. until the list of outputs is complete.
Bang to the right inlet sends out midi inputs.
You can then use the umenu objects to set noteout, ctlout, pgmout, etc., to a midi device name. Hook the middle outlet of umenu to all of your output objects and you have a one-stop choosing object.
loadbang and loadmess
You can imagine that wanting to perform a taks like listing the available midi inputs is something that you’d like to perform each time you load the patcher. loadbang and loadmess can help you automate this task. loadbang outputs a bang when the complete patcher (and any subpatchers) has loaded. loadmess performs a similar function, outputting the message provided as an argument upon patcher load. Although I’ve included the bang button in the patcher, you do not need it. Double-clicking either the loadbang or loadmess objects will trigger output.