Relate on import

This attempts to relate emails better on import from user's email accounts.

First I match based on known email addresses, using precedence:

Contact > Lead > User

From > To > CC

I also set Status = Sent, when the email has been imported to Espo via a Users IMAP folder. (We don't scan Inbox we scan an 'Espo' folder.

Then I check for a MesssageId which matches the format set in 0299f300 and use that information if available. This means emails link against Cases / Opportunities automatically on import.

I also remove the case number feature from subject lines as auto-relating takes care of this.

Some of these changes might not be deemed relevant but here they are anyway.
Unforunately GMail modifies message Id header of received email. So references and reply to id are messed up if email is replied from GMail client. Do you know about this issue?