Modified IMAP agent to create an event for each message and fixed BEFORE/SINCE logic