Back in 1993 or so, hanging around the computer lab at Rutgers, I used to watch people play muds a lot. Rutgers' camden campus hosted a very popular early MUD (MUSH, MOO, the differences here are irrelevant here) called "Nails". (This was shortly before the rise of commercial ISPs, when almost all broadband connections belonged to some university or corporate bean counter. Being able to run a relatively frivolous program on a broadband net connection 24/7, for years at a time, was still a rare and special thing. Nails was allowed as a permanent daemon on a Rutgers terminal because it had been approved/created as a student project (possibly a thesis), and continued running the whole time he was there and I think even after he graduated. (The campus network administrator was Stan Kolasa, who would know the details.))
Although you could use Nails to go around a beat up monsters in a zork-ish way, its real function was a great big series of chatrooms, ala IRC. People would go into the same room and type at each other. The users were mostly college students, but since anybody could create an account through the net, not all of them were going to Rutgers. (People found out about it by word of mouth.)
And one thing that would come up in discussion among these college students was Monty Python, and one of Python's most popular bits is the Viking Spam Sketch (in which people attempting to order dinner in a british cafe repeatedly have their conversation drowned out by the group of vikings at the bar singing a song with lyrics consisting of the word "spam", repeated over and over. Go rent the DVD.)
And invariably when this happened, somebody would start typing "spam spam spam spam spam" in the IRC-esque MUD room, and use the "cursor up" key to repeat it. Pretty soon they'd start drowing out everybody else's conversations by typing a big five-line block repeating that one word, then cursor up to repeat a few more times, so that anything anybody else typed scrolled off too quickly to read.
The first time, this was actually funny for about 15 seconds.
It only took a couple occurrences of this phenomenon for it to become known as "spamming the channel" (or room). (Just enough occurrences to migrate from "funny" to "annoying" without stopping, since some newbies found it funny and other people were too socially maladjusted to give up on anything that had once gotten a laugh.) Of course people could and did repeat _other_ lines of conversation (it was easy, cursor-up/down gives you a command history, so cursor up and hit enter to repeat the last line), and would do so when frustrated or malicious or whatever, and once the phenomena had been _named_ it became natural for people to ask them to "stop spamming". It also became natural for the techies running the chat rooms to write "spam killer" that would detect when somebody had posted the exact same line several times in a row, and either filter the messages or log that user out. (Technically, this was trivial to do. It also helped cement the name.)
The term "spamming" spread naturally from chat room repetitions to excessive cross-posting in usenet. (Not commercial usage yet, that didn't come for another year or so, and didn't become COMMON for about five more, but simply posting a message and cc: way-too-many-other-groups. This was another common thing newbies did because they didn't know any better.) In usenet, it developed connotations of "off-topic" posts, since truly excessive crossposts tended to have only a tentative connection to some of the groups they were posted in. (Just because you talk about star trek, beer, and your cats in one post is _not_ an excuse to cc: the same post to newsgroups on each topic.)
This is where the widely known history picks up:
The current name for junk email can easily be traced back to usenet. The first commercial spam messages were posted to usenet, and were originally just a _type_ of spam: Off-topic crap cross-posted by a clueless newbie. As commerical posts gradually became more of a problem than excessive cross-posting, they became the dominant type of usenet spam. And since cross-posting is seldom a problem in email, but automated address harvesting and bulk mailing by soulless money-grubbing bastards is, when the term "spam" jumped to email it applied solely to unsolicited commercial messages.
But most historians who weren't there haven't been able to track it back to chat rooms, because there are no archives of those conversations. "Spamming" as a verb originated with college students discussing Monty Python in chat rooms, who noticed that hitting cursor-up and enter several times in a row gave them the power to drown out other people's conversations, and thought it was funny. (It might be possible to dig up old MUD "spam killer" filter software from the early 90's to date it more accurately. My best guess is 1993.)