Don't treat someone as "a crank" to begin with
I'm going to put forward a slightly alternative take on this than the other answers. While I agree with some of the practical suggestions for a polite dismissal of interest in work that is not fruitful, I think it is a bad idea to begin with the dehumanising premise that a person is "a crank". People described in this way can more accurately be described as amateur analysts with substantial gaps in their knowledge, which lead them to attempt to solve problems that they are ill-trained for, or use methods they misunderstand. Sometimes (though not always) this is combined with a skepticism of existing authorities in the field.
I agree with the general view that one should ignore non-meritorious contact, and in most cases a deleted email is the solution. However, if academics do choose to engage in discussion with amateur analysts of this kind, I think it is incumbent on the academic to show the same kind of basic humanity, decency, patience and politeness that would be used with an undergraduate, grad-student, etc. If the work at issue is extremely poor, it will not generally be frutiful to wade into its details, though one might outline some basic errors or false premises if that is simple to do. Irrespective of this, a reasonable thing to do here (if you choose to communicate at all) is to direct the amateur analyst to resources that they can follow to allow them to discover the problems with their method on their own. If the analyst is operating at a level where those resources are too hard (e.g., they lack sufficient training in a particular field), you might instead recommend courses or books that will give them more training in a particular subject.
One of the things that can be observed about extreme cases of "cranks" is that if they are cut off completely from academic feedback, particularly in the early years, this may lead them to proceed hermetically, and some can work for many years ---or even decades--- developing a long and detailed theory without merit. I suspect that early cases of hostile or condescending rejections from the academic world (combined with the snarky dehumanising attitude exhibited on forums like this) sometimes lead such people to believe that academia is corrupt and insular, which makes them more inclined to proceed without any effective check on their work.** I'm not sure if anything can prevent this, but it seems like it might be worthwhile if such people were directed early on to useful learning resources, in a way that grants them some dignity, and some sympathy for the fact that they are trying their best to solve problems with the skills they have at their disposal (not unlike our students).
** And let's be honest; academia sometimes is corrupt and insular.