And sure, this could be an email (all of the same principles would apply), but a letter makes things official in every sense. It also gives you a prop to take along to the face_to_face meeting with your boss, when you let him or her know that you're leaving.
The Thank You. Next, it's always a good idea to thank your employer for the opportunity, describing some of the key things you've enjoyed and learned on the job. And yes, this is true even if you're thrilled to be leaving. Remember__you may need these people for a reference down the line, and leaving things on a good note will leave a lasting (positive) impression.