forked from gopavasanth/Automate-Status-Updates
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmsgs.py
More file actions
61 lines (47 loc) · 1.47 KB
/
Copy pathmsgs.py
File metadata and controls
61 lines (47 loc) · 1.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
"""Get Message with given ID.
"""
# Gopavasanth
# Date : 05/05/2018
from __future__ import print_function
import httplib2
import os
from apiclient import discovery
from oauth2client import client
from oauth2client import tools
from oauth2client.file import Storage
import sending_mail
try:
import argparse
flags = argparse.ArgumentParser(parents=[tools.argparser]).parse_args()
except ImportError:
flags = None
import auth
import mesages
SCOPES = 'https://mail.google.com/'
CLIENT_SECRET_FILE = 'client_secret.json'
APPLICATION_NAME = 'Gmail API Python Quickstart'
authInst = auth.auth(SCOPES,CLIENT_SECRET_FILE,APPLICATION_NAME)
credentials = authInst.get_credentials()
http = credentials.authorize(httplib2.Http())
service = discovery.build('gmail', 'v1', http=http)
import base64
import email
from apiclient import errors
def GetMessage(service, me , msg_id):
"""Get a Message with given ID.
Args:
service: Authorized Gmail API service instance.
user_id: User's email address. The special value "me"
can be used to indicate the authenticated user.
msg_id: The ID of the Message required.
Returns:
A Message.
"""
try:
message = service.users().messages().get(userId=user_id, id=msg_id).execute()
#print ( 'Message snippet: %s' ) % message['snippet'] )
return message
except errors.HttpError, error:
print ('An error occurred: %s' % error)
msgs = GetMessage(service, 'gopavasanth1999@gmail.com', '165b9b169d397eef')
print (msgs)