I'm going to ignore all the people above who somehow think it's funny to make fun of people with a mental illness or those who have been so depressed or frustrated as to attempt to take their own life.
I fall into the same boat as the original poster. I tried to take my own life over something STUPID, and now, many years later I have a 2nd class medical and fly often.
So, yes..it's possible. But definitely be able to document your road to treatment, drugs taken, years of counseling, etc. Talk to a qualified AME about the situation.
Shame on those people who think this is some joke. I hope you never experience the pain it takes to actually go so far as to take your own life. It's not trivial, it's not casual and it sure as hell isn't funny.