Ok, you open the courierimapuiddb file and look for the msgnum, then the filename will be there.
i.e.
MSGNUM FILENAME
------ ---------------------------------------------------
302 1275038115.H259797P9718.server.myhost.com,S=1536456
304 1275051597.H812919P25674.server.myhost.com,S=936114