Skip to content
This repository has been archived by the owner on Sep 27, 2021. It is now read-only.

New keywords and encoding handling #11

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion src/ImapLibrary/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class ImapLibrary(object):
ROBOT_LIBRARY_VERSION = VERSION
ROBOT_LIBRARY_SCOPE = 'GLOBAL'

port = 993
port = 143
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you make this configurable (with 993 as default) as this is a breaking change ?


def open_mailbox(self, server, user, password):
"""
Expand Down Expand Up @@ -99,8 +99,30 @@ def get_email_body(self, mailNumber):
`mailNumber` is the index number of the mail to open
"""
body = self.imap.fetch(mailNumber, '(BODY[TEXT])')[1][0][1].decode('quoted-printable')
body = body.decode('utf-8')
return body

def get_email_title(self, mailNumber):
"""
Returns an email title

`mailNumber` is the index number of the mail to open
"""
subject = self.imap.fetch(mailNumber, '(BODY[HEADER.FIELDS (SUBJECT)])')[1][0][1].lstrip('Subject: ').strip() + ' '
subject, encoding = email.Header.decode_header(subject)[0]
print subject
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

printf debugging

title = subject.decode(encoding)
return title

def remove_all_mails(self)
"""
Marks all received mails as deleted and removes those
"""

for mail in self.mails:
self.imap.store(mail,'+FLAGS', '\DELETED')
self.imap.expunge()

def _criteria(self, fromEmail, toEmail, status):
crit = []
if fromEmail:
Expand Down