Skip to content

Commit

Permalink
Merge pull request #7 from macejiko/master
Browse files Browse the repository at this point in the history
Fix for Mark All Emails As Read
  • Loading branch information
lasselindqvist committed Dec 18, 2019
2 parents 45d3677 + c17bdd1 commit 11d052f
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/ImapLibrary2/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,7 @@ def delete_all_emails(self):
Examples:
| Delete All Emails |
"""
typ, mails = self._imap.uid('search', None, 'ALL')
self._mails = mails[0].split()

self._get_all_emails()
for mail in self._mails:
self.delete_email(mail)
self._imap.expunge()
Expand Down Expand Up @@ -217,6 +215,7 @@ def mark_all_emails_as_read(self):
Examples:
| Mark All Emails As Read |
"""
self._get_all_emails()
for mail in self._mails:
self._imap.uid('store', mail, '+FLAGS', r'\SEEN')

Expand Down Expand Up @@ -408,3 +407,10 @@ def _start_multipart_walk(self, email_index, msg):
self._email_index = email_index
self._mp_msg = msg
self._mp_iter = msg.walk()

def _get_all_emails(self):
"""Saves all existing emails to internal variable."""
typ, mails = self._imap.uid('search', None, 'ALL')
self._mails = mails[0].split()


0 comments on commit 11d052f

Please sign in to comment.