You sound genuinely contrite about this incident. If you live in block of flats I am not sure whether it is never right to have a loud party at all, but if you do, to let your flat neighbours know so they could go out that evening if they chose to. Also midnight would be a reasonable hour ro finish in a block of flats.
I would definitely write a very short note to start with, expressing your remorse. You do not need to go into details, but I would print off your long posting and enclose that. From that he will see all the things you need to get over without you labouring the point and he will see that the uninvited guests were the problem etc.
Good luck. Do let us know how you get on. If I were to read what you had written, in his place, it would make a lot of difference to how I reacted the following day.