Be very careful not to alienate your boss when you leave. You may need his reference later on.
Give at least 2 weeks' notice, although 3 or 4 may be required if you have been with the company for some years. Your contract will specify the minimum time that you must give. If you're in the middle of an important project, ask your new boss if you can stay until it's finished. Whether the answer is yes or no, your commitment to your old employer will be respected.
Your letter of resignation is part of your permanent personnel file. Keep it simple and factual. If you're leaving because you are unhappy, don't put this or your reasons in the letter.
Offer to train your replacement. If no one has started before you go, leave a list of things the new person should know. Make copies for your boss, your successor and any relevant colleagues.
Tell your most important contacts you're leaving and give them the name of your replacement.