Can a pregnant woman's emotional state affect her baby? Can it do so to such an extent that when the baby grows up it suffers from psychological problems?
Yes, a mother's emotional state can, unfortunately, adversely affect the fetus, and the effect can in some cases can be long-lasting.
To put it simply, your genetic code is the blueprint of your physical, and to some degree your cognitive, self. Just as many desirable and undesirable conditions have a genetic basis, so too are more and more psychological conditions being found to have a genetic component (as well as an environmentsl component that extends into the intrautering environment, but I'll ignore that now.)
However, stress can actually alter the way DNA (your genetic code) is read; this is epigenesis - a change above the level of DNA that changes the expression on one's genes. There are many studies now suggesting an epigenetic role in adult depression stemming from childhood trauma (e.g. child abuse).
Studies also show that maternal stress can cause epigenetic changes in utero. Most of the studies are animal studies with very significant stressors - like diabetes, malnutrition (enough to cause intrauterine growth retardation), etc., but it is likely that less severe stressors can likely cause some epigenetic changes.
The science here, though, is in it's infancy, and no predictions can be made. What should be kept in mind is that millions of women every year have high-stress pregnancies (some incredibly so) yet deliver infants who grow into well-adjusted adults.
Child Abuse, Depression, and Methylation in Genes Involved With Stress, Neural Plasticity, and Brain Circuitry
DNA methylation analysis of multiple tissues from newborn twins reveals both genetic and intrauterine components to variation in the human neonatal epigenome