Andrew Stacey covered this briefly, but I want to re-emphasize:
If you are an undergraduate it is unlikely that you have questions that actually require asking the expert in something. If you're at an institution with a graduate program (this may be different at a liberal arts college) you ought to be able to find someone local you can ask instead. This way you can talk in person (which is an easier way to communicate), you can ask during someone's office hours (when they're in their office answering questions anyway), and you're building connections with professors at your school who might write you letters in the future.
Furthermore, if the professor you ask locally doesn't know the answer, they'll be able to point you to a friend of theirs who will know the answer. That way you can start your letter "Hi, I'm a student at school X and Prof. Y suggested you might know the answer to the following question."
In graduate school things are a bit different, you're more likely to have a question that really does need to be asked of a particular person, and you're more likely to know whether the question is a good use of that person's time. Furthermore, as a graduate student you'll want to start getting to know the experts in your field at different schools. So, if your advisor doesn't know the answer to a question you shouldn't hesitate to email someone who you think would know the answer.