Completed IMAP parsing script (except deletion)