IMAP

After creating an IMAP connection in Dashboard, messages can be fetched, mark as seen and deleted, as in the examples below.

Receiving e-mails

# -*- coding: utf-8 -*-

# Zato
from zato.server.service import Service

class MyService(Service):

    def handle(self):
        conn = self.email.imap.get('My Connection').conn

        for msg_id, msg in conn.get():

            # Access the message
            self.logger.info(msg.data)

Marking messages seen

Call .mark_seen() on a message object to mark it as seen.

from zato.server.service import Service

# -*- coding: utf-8 -*-

# Zato
class MyService(Service):

    def handle(self):
        conn = self.email.imap.get('My Connection').conn

        for msg_id, msg in conn.get():

            # Access the message
            self.logger.info(msg.data)

            # To mark the message seen
            msg.mark_seen()

Deleting messages

Call .delete() on a message object to mark it as deleted.

# -*- coding: utf-8 -*-

# Zato
from zato.server.service import Service

class MyService(Service):

    def handle(self):
        conn = self.email.imap.get('My Connection').conn

        for msg_id, msg in conn.get():

            # Access the message
            self.logger.info(msg.data)

            # To delete the message
            msg.delete()