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 so-called "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 leads 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).
The final helpful thing in dealing with such cases is to highlight the benefits of blinded peer review as a useful tool for amateur researchers. We all know that peer review has its problems, but whatever its faults, it is an extremely useful source of assistance in academic writing, particularly for researchers who are inexperienced in publication of work in academic journals. Use of blinding protocols should put amateur researchers somewhat at ease if they are concerned that academia is an exclusive club that discriminates against outsiders. Helping such researcher simplify and clarify their work, and present it to the rigours of blinded peer review, is something that could potentially be very valuable for any researcher with the patience to assist. As professional academics, we are extremely patient with our own students (many of whom are appallingly ignorant) so let's extend that patience and courtesy more broadly.
** And let's be honest; academia sometimes is corrupt and insular.