'mark Email Flag Queue of self.email_account mails as read'

def mark_emails_as_read_unread(self):

    if (not self.use_imap):
        return
    flags = frappe.db.sql(u"select    name,    communication,    uid,    action    from\n DCTB  DCTB  DCTB `tabEmail    Flag    Queue`    where    is_completed=0    and    email_account='{email_account}'\n DCTB  DCTB  DCTB ".format(email_account=self.name), as_dict=True)
    uid_list = {flag.get(u'uid', None): flag.get(u'action', u'Read') for flag in flags}
    if (flags and uid_list):
        email_server = self.get_incoming_server()
        if (not email_server):
            return
        email_server.update_flag(uid_list=uid_list)
        docnames = u','.join([(u"'%s'" % flag.get(u'communication')) for flag in flags if (flag.get(u'action') == u'Read')])
        self.set_communication_seen_status(docnames, seen=1)
        docnames = u','.join([(u"'%s'" % flag.get(u'communication')) for flag in flags if (flag.get(u'action') == u'Unread')])
        self.set_communication_seen_status(docnames, seen=0)
        docnames = u','.join([(u"'%s'" % flag.get(u'name')) for flag in flags])
        frappe.db.sql(u'    update    `tabEmail    Flag    Queue`    set    is_completed=1\n DCTB  DCTB  DCTB  DCTB where    name    in    ({docnames})'.format(docnames=docnames))
