The less said in any sympathy card, the better. This one is really tricky because of the mixed feelings going on. So even more important just to keep it short. The point is that you are expressing sympathy and solidarity at a tough time, so the content isn't the issue. It's not the time for creativity or even overpersonalization. Traditional, simple, formulaic words are the best for sympathy. In our Jewish community, people often write very little or even nothing beyond the traditional Hebrew greeting for a mourner, which is just a few words.
Don't ever tell someone how to feel. "She's better off now" or "You should be glad he's no longer suffering" are well intended but awful.
Don't try to say something that minimizes their loss in an effort to make them feel better. I had a miscarriage many years ago, unfortunately right after Time Magazine had done a piece about how miscarriage is much more common than we knew, because it can happen so early in a pregnancy that the woman didn't even realize she was pregnant. Several people mentioned that to me, as if I shouldn't feel bad at all because it's so common. Why on earth think that? You wouldn't think you were cheering up a friend who'd just lost her mother by pointing out that it's common for children to outlive their parents. The effect was just to make me feel much worse, as if I not only had a loss, I wasn't supposed to care and my feelings weren't legitimate. (I wasn't freaking out or in mourning or anything.)
Similarly, don't say "I know how you feel" or talk about a loss you have had ("I remember when my dad died ..."). You DON'T know how they feel, and they don't want to hear that their experience is ordinary.
If I knew the person at all, I try to say something nice I remember about them; that's the only thing I add to a very short message of sympathy. People really seem to appreciate that most of all.
I am so sorry to hear of your loss. Whenever I think of your dad, I remember him smiling and helpful to others [OR: although I never met your dad, I know you always looked forward to vacations with him/I am sure he was proud of you and your family/etc.].
May he rest in peace, and may you and your family find comfort in many happy memories.
But you can't do that here with a newborn baby. So just keep it very short -- as I said above, it's the fact you are doing it at all that matters. Don't say anything about the other, happy news in their life -- do that separately. Inviteseller's formula is excellent. Here is another one if you like:
I am so terribly sorry to hear of the loss of little Mervin. Please know that we are all thinking of you.
Sharnita, your note is lovely, but I would caution against one thing. It's great to help, but don't make it an "if" or tell them to ask you if they NEED it. That's why, in my opinion, although the sentiment is perfect, I'd avoid the wording "If you need a meal or a friend to talk to, don't hesitate to call for either." No one is going to call you and ask you for a meal or to ask you to come over now so they can cry. Just bring the meal and just visit. Particularly tricky are things along the line of "If you need a shoulder to cry on ...." People HATE that. It sounds like you are hungry for the interesting spectacle of their pain, or perhaps wanting to set yourself up as their most important friend and confidante for your own gratification (I know that is NOT what you meant!). If it's a close enough friend that you are a natural person for that, then just BE THERE.
Really, in the end, I think that's what love and friendship are all about -- being there. And that's what sympathy notes symbolically are: helping people in sorrow feel that they are not alone.