Google api: how to attach a file from google drive?

Sending mail through gmail with attachments, or downloading the file from the drive no problem.

but how to attach a file located on google drive - in docks did not find, who can faced.
for earlier big senks :)
language (Python, Oauth2 authorization.)
June 3rd 19 at 19:03
1 answer
June 3rd 19 at 19:05
It is enough to add a link to the file.

from __future__ import print_function
from googleapiclient.discovery import build
from httplib2 import Http
from oauth2client import file, client, tools
from qs import CreateMessage, SendMessage

SCOPES = 'https://www.googleapis.com/auth/gmail.send'

def main():
 """Shows basic usage of the Gmail API.
 Lists the user's Gmail labels.
"""
 store = file.Storage('token.json')
 creds = store.get()
 if not creds or creds.invalid:
 flow = client.flow_from_clientsecrets('credentials.json', SCOPES)
 creds = tools.run_flow(flow, store)
 service = build('gmail', 'v1', http=creds.authorize(Http()))

 message = CreateMessage('xxx@gmail.com',
'yyy@inbox.ru',
'test',
'https://docs.google.com/spreadsheets/d/xxx/edit?usp=sharing')
 SendMessage(service, 'me', message=message)

if __name__ == '__main__':
 main()


Probably is the option that she have to share files for everyone, if necessary.

Find more questions by tags PythonGmailGoogle Drive