If you don't know who is going to be getting the letter, then you address it to "Dear Madam or Sir." If you do know the person, then you almost always know whether the person is a Madam or a Sir. If you know the person but still aren't sure whether the person would prefer Madam or Sir, then ask the person whether "he" or "she" is the preferred pronoun and extrapolate from that. If you there's not opportunity for you to ask the person's preference, then just make a guess. Trust me, that person has experience dealing with those who try to be polite and make an honest mistake. The person will help you know what to do, will say something like "It's 'Ms. Perry Baldwin' please."