Rabbeinu Gershom issued a Cherem (ban) on unauthorized reading of private letters.
I would like to know how books which contain private correspondence or sh'elos us'shuvos between Rabbis and other people are published?
With regards to private letters, generally with permission from both sides. That is how the Lubavitcher Rebbe's letters are published. You even see parts redacted at the request of the recipient.
Regarding sh'elos us'shuvos: Embarrassing someone in public was already ossur before Rabbeinu Gershom. But if the information does not have that concern, the cherim is only on curiosity looking, and only if it doesn't have a spiritual purpose. Publishing Torah is certainly a purpose for which the Cherim does not apply (as described in your link):