If you are writing to someone who has a doctorate or medical degree, use the abbreviated form: "Dr." However, for other titles, such as professor, judge, rabbi, etc., write out the full title and capitalize it. For example, your salutation in a letter to a judge would be, "Dear Judge Barnard." Or, if your correspondence was with a rabbi, you might write, "Dear Rabbi Williams."
Formal communication is on the wane in modern life, but there are still times when it's the only correct way to reinforce a connection or convey information. If you're applying for a job, looking for a recommendation, or expanding your network, err on the side of formality. Don't let the slightly archaic feel of a formal business letter tempt you into using flowery, outdated language.