
\documentclass[french]{article}
  \usepackage{ifthen}
  \pagestyle{empty}

\newcommand*{\ecrireLettre}[1]{%
\hspace{4ex}%
\ifthenelse{\equal{#1}{M}%
            }{Cher Monsieur,}{Chère Madame,}

J'ai le plaisir de vous inviter\dots
}

\begin{document}

\ecrireLettre{F}

---

\ecrireLettre{M}

\end{document}
