T
teja
Hi,
I have a requirement that I want to log-in into a gmail account read
all unread mails, mark them as read and then archive them.
I am using libgmail (version 0.1.11) library to do so, using which I
am able to log-in into a gmail account fetch all unread message and
then read them one by one.
Now my problem is that I am not able to mark the unread mail as read
and archive it.
Below is sample code that I am using.
from libgmail import *
ARCHIVE_ACTION='rc_^i' #the action string to archive a message
UNREAD_MAILS = "is:unread"
def ArchiveAll():
ga = GmailAccount(name='username', pw='password')
print 'logging in...',
ga.login()
print 'successful'
def _getAllUnreadMails():
return ga.getMessagesByQuery(UNREAD_MAILS, True)
def _readMail(email):
emailData = ga.getRawMessage(email)
def _archiveAndMarkRead(email):
ga._doThreadAction(ARCHIVE_ACTION, email)
ga._doThreadAction(U_MARKREAD_ACTION, email)
emails = _getAllUnreadMails()
for email in emails:
eData = _readMail(email)
#Process email data
_archiveAndMarkRead(email)
print 'done'
if __name__ == '__main__':
ArchiveAll()
after executing this code I am getting following error
HTTP Error 500: Internal Server Error
Traceback (most recent call last):
File "test_libgmail.py", line 30, in <module>
ArchiveAll()
File "test_libgmail.py", line 26, in ArchiveAll
[_archiveAndMarkRead(t) for t in sr[1]]
File "test_libgmail.py", line 21, in _archiveAndMarkRead
ga._doThreadAction(ARCHIVE_ACTION, thread)
File "/home/3rdparty/libgmail/libgmail.py", line 669, in
_doThreadAction
items = self._parsePage(_buildURL(**params))
File "/home/3rdparty/libgmail/libgmail.py", line 383, in _parsePage
items = _parsePage(self._retrievePage(urlOrRequest))
File "/home/3rdparty/libgmail/libgmail.py", line 99, in _parsePage
lines = pageContent.splitlines()
AttributeError: 'NoneType' object has no attribute 'splitlines'
Can anyone help me in figuring out what's going wrong here?
I guess google has deprecated this way of marking emails, correct me
if I am wrong here.
But if its true, is there any other way or library in Python to meet
my requirements?
Thanks in advance.
I have a requirement that I want to log-in into a gmail account read
all unread mails, mark them as read and then archive them.
I am using libgmail (version 0.1.11) library to do so, using which I
am able to log-in into a gmail account fetch all unread message and
then read them one by one.
Now my problem is that I am not able to mark the unread mail as read
and archive it.
Below is sample code that I am using.
from libgmail import *
ARCHIVE_ACTION='rc_^i' #the action string to archive a message
UNREAD_MAILS = "is:unread"
def ArchiveAll():
ga = GmailAccount(name='username', pw='password')
print 'logging in...',
ga.login()
print 'successful'
def _getAllUnreadMails():
return ga.getMessagesByQuery(UNREAD_MAILS, True)
def _readMail(email):
emailData = ga.getRawMessage(email)
def _archiveAndMarkRead(email):
ga._doThreadAction(ARCHIVE_ACTION, email)
ga._doThreadAction(U_MARKREAD_ACTION, email)
emails = _getAllUnreadMails()
for email in emails:
eData = _readMail(email)
#Process email data
_archiveAndMarkRead(email)
print 'done'
if __name__ == '__main__':
ArchiveAll()
after executing this code I am getting following error
HTTP Error 500: Internal Server Error
Traceback (most recent call last):
File "test_libgmail.py", line 30, in <module>
ArchiveAll()
File "test_libgmail.py", line 26, in ArchiveAll
[_archiveAndMarkRead(t) for t in sr[1]]
File "test_libgmail.py", line 21, in _archiveAndMarkRead
ga._doThreadAction(ARCHIVE_ACTION, thread)
File "/home/3rdparty/libgmail/libgmail.py", line 669, in
_doThreadAction
items = self._parsePage(_buildURL(**params))
File "/home/3rdparty/libgmail/libgmail.py", line 383, in _parsePage
items = _parsePage(self._retrievePage(urlOrRequest))
File "/home/3rdparty/libgmail/libgmail.py", line 99, in _parsePage
lines = pageContent.splitlines()
AttributeError: 'NoneType' object has no attribute 'splitlines'
Can anyone help me in figuring out what's going wrong here?
I guess google has deprecated this way of marking emails, correct me
if I am wrong here.
But if its true, is there any other way or library in Python to meet
my requirements?
Thanks in advance.