An updated pull request is at https://github.com/mguessan/davmail/pull/353 based on Peter's work above.