I suddenly started having this problem about two weeks ago.
Mail only crashes when I am emptying iCloud email. I have three other IMAP accounts set up in Mail and I can happily empty the deleted messages in those and Mail works perfectly. It is only when emptying trash for the iCloud account in Mail. The crash occurs if I right-click on the iCloud account trash and select Erase Deleted Items ..., go to the Mailbox menu and select Erase Deleted Items (either all accounts or the single account), or if I go into the Trash mailbox, select all and press delete. All options cause the crash and generate a similar error message: "Crashed Thread: 14 Dispatch queue: IMAPNetworkTaskHandler queue :: NSOperation 0x7f9aaee39db0 (QOS: USER_INITIATED)"
I've also noticed that moving a group of messages from the iCloud inbox to trash is very slow at times. When deleting from Gmail or Comcast accounts, the message about moving the emails never even appears it happens so quickly; not so with the iCloud account.
This is happening both on my MBP running El Capitan and my iMac running High Sierra. And, the issue started on both computers at essentially the same time. I have rebuilt mailboxes, deleted the index so it would be rebuilt and even went so far as to turn off iCloud email (thereby deleting the account) and then turned it back on so that all the many thousands of emails were re-downloaded from iCloud ... all to no avail.
I am an Apple specialist so I have gone through both computers with a fine tooth comb searching for issues. Given that the error is always the IMAPNetworkTaskHandler, and the fact that this issue is occurring on multiple operating systems, I believe that the problem is at the server end. Like others, I have managed to have the problem disappear for a day or three, but the problem always comes back and it's always the iCloud IMAP account, none of the other three. Of course, calling AppleCare they will tell you that your computer is broken even though the issue is apparent on multiple computers.
As far as deleting the email at iCloud ... that works but upon launching Mail (after emptying trash at icloud.com), there is a crash as soon as Mail tries to synchronize the fact that the Trash is now empty, generating the same IMAPNetworkTaskHandler error.
Not much help, I know ... :(