How do you write a query letter?
If you were to type this question into Mr. Google's search engine, you're probably going to get millions and millions of hits. Most of them are going to be similar, so let me sum it up for you.
(You may ask, why should I take advice from you, since none of your novels have been published? I understand your inquiry, however even though no agents at this point have signed up to represent me, a handful have looked favorably onto my query letter and have asked to see a few sample chapters--one even asked to see my very first novel. Also, I've read quite extensively on this subject, so I do have first-hand knowledge of the subject.)
First and foremost, your manuscript needs to be complete and thoroughly edited. If it is, then let's move on. If it's not, then go back to work and finish it. The vast majority of agents will reject you if your manuscript isn't complete. There are a few exceptions to the rule, but you have to be one damn talented fellow in order to move forth through the gauntlet AND something special--like a psychologist who's been practicing for twenty years with troubled teens and have a wealth of information to share. That kind of special. Not a oh-I-think-I-can-write-like-J. K. Rowling (or whoever your favorite author it)-just-because-I've-read-all-of-the-Harry-Potter-novels. Keep working.
Manuscript complete? Check.
Thoroughly edited? Check.
Good. Let's move on. At the top of the page, put today's date, then put in your contact info (put e-mail address, cell phone number, and even a blog website if it showcases your writing) right below that. Next put in the agent's address.
For the salutation, find out the name of the agent you're sending it to. DO NOT send it to the attention of Mr. or Mrs. Literary Agent. Chances are it'll be rejected. Make it personal and put in their name.
For the body of the e-mail, there are a few formats to choose, so experiment a little to find the right one. It should contain: your name and also why you're contacting them (looking for an agent to represent me), three to five sentences on what your book is about, and a brief history of yourself. Finish your letter by thanking them for their time, and if they're interested, you could either send them a few chapters or the entire manuscript to review.
Lastly, keep your query letter down to one page. Any more than that, and you'll probably be rejected. Think of the query letter as a sales pitch, an elevator pitch. Keep it short.
Sounds fairly simple, doesn't it?
Try it. In fact, even if you're currently working on a novel right now, start your query letter immediately. That way, when it's done, you can go back and tweak it. I even suggest having a few people read it (preferably not family, as they can be a little biased towards you) and ask for their honest opinion.