Here's my take on some of these issues:
I agree with Layla. If you want to write great songs you must write lots and lots of songs, not all of which will be great. Quality only exists in the midst of quantity. To develop your ability you must become a constant writer, keeping your mind constantly engaged in working out the puzzles of songwriting.
I agree w/ Philboyd. At it's genesis, creativity is simply copying something you like. You can cloak it in terms such as "inspiration" or "influence", but it's all the same thing.
I disagree w/ Ektronic. Books can help. I highly recommend
this one. 
Creativity and "rules" are not mutually exclusive. Knowledge is power, and any time I can gain knowledge from someone w/ more experience than me, be it via song coaching or lessons, a book, co-writing, or whatever, I am all over it!
As far as grn's original question, there is no "sure fire" way to write a good melody. Of that I'm sure. Here are some things I try to keep in mind:
1: Keep your phrases short, sometimes even as few as two or three notes per phrase. This makes your melody more memorable. The opening phrase that begins the melody for "Hey Jude" begins with two notes. Every phrase that follows is short. Pretty memorable, huh?
2: Keep your melody linear (going up and down a scale without lots of big interval jumps). This makes it easier to sing.
3: Write the hook of your melody so that it makes it clear where the title goes - even when the lyrcs aren't being sung. Use a dramatic pause or a sudden change in register to surprise the listener.
Writing great melodies is a never-ending quest.
A
www.aaroncheney.com