jeremyephron / simplegmail

A simple Gmail API client for applications in Python
MIT License
352 stars 74 forks source link

How to create a draft email #115

Open kishoreKunisetty opened 6 months ago

kishoreKunisetty commented 6 months ago

i can see send and read emails but i'm not able to find how to write drafts using this package. if anyone is aware of this implementation please help me with it.

psresnik commented 3 months ago

I don't see any ability to create drafts in the simplegmail package. However, its Gmail class contains the service object for the Gmail API, and it looks like one should be able to do this as in https://stackoverflow.com/questions/46170469/gmail-api-create-draft-reply:

msg = create_message('YOU@gmail.com','THEM@company.com','Re: Some Subject','This is a test')
create_draft(service,'me',  msg)

which makes use of the code at https://developers.google.com/gmail/api/guides/drafts#python.

I have not tried this myself yet but thought I'd share what I found.