General synonyms:
* Sadness
* Dejection
* Gloom
* Despondency
* Mournfulness
* Wistfulness
More specific synonyms:
* Pensive (thoughtful and sad)
* Brooding (deeply thoughtful and unhappy)
* Sorrowful (filled with sorrow)
* Downcast (depressed and disheartened)
* Disconsolate (without hope or consolation)
Literary synonyms:
* Elegy (a poem or song expressing sorrow or lamentation)
* Lament (to express sorrow or regret)
* Dirge (a mournful song or piece of music)
The best synonym for melancholy will depend on the context of your writing.