janja-janja / gmail-api-wrapper

Gmail API Wrapper - A Python Client
https://pypi.python.org/pypi/gmail-api-wrapper/
Other
26 stars 2 forks source link

AttributeError: MIMEText instance has no attribute 'as_bytes' #14

Open Zhanweelee opened 4 years ago

Zhanweelee commented 4 years ago

environment: Linux instance-1 4.9.0-6-amd64 #1 SMP Debian 4.9.88-1+deb9u1 (2018-05-07) x86_64 GNU/Linux pip: gmail-api-wrapper==0.1.1a2

code:

# -*- coding: utf8 -*-
from gmail_api_wrapper.crud.write import GmailAPIWriteWrapper

api = GmailAPIWriteWrapper()
# compose new mail
import datetime
nowstr = datetime.datetime.strftime(datetime.datetime.now(), "%Y-%m-%d %H%M%S")
subject = "test"
body = nowstr
print api.compose_mail(subject=subject, body=body, to='xxxx@gmail.com')

error:


Traceback (most recent call last):
  File "sendmail.py", line 10, in <module>
    print api.compose_mail(subject=subject, body=body, to='xxxx@gmail.com')
  File "/xxxxx/.local/lib/python2.7/site-packages/gmail_api_wrapper/crud/write.py", line 92, in compose_mail
    b64_raw = base64.urlsafe_b64encode(message.as_bytes())
AttributeError: MIMEText instance has no attribute 'as_bytes'