Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit6bc2e82

Browse files
committed
update gmail api tutorial
1 parentcefe1a2 commit6bc2e82

File tree

4 files changed

+322
-302
lines changed

4 files changed

+322
-302
lines changed

‎general/gmail-api/delete_emails.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
defdelete_messages(service,query):
44
messages_to_delete=search_messages(service,query)
5+
print(f"Deleting{len(messages_to_delete)} emails.")
56
# it's possible to delete a single message with the delete API, like this:
67
# service.users().messages().delete(userId='me', id=msg['id'])
78
# but it's also possible to delete all the selected messages with one query, batchDelete

‎general/gmail-api/mark_emails.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
defmark_as_read(service,query):
44
messages_to_mark=search_messages(service,query)
5+
print(f"Matched emails:{len(messages_to_mark)}")
56
returnservice.users().messages().batchModify(
67
userId='me',
78
body={
@@ -12,6 +13,7 @@ def mark_as_read(service, query):
1213

1314
defmark_as_unread(service,query):
1415
messages_to_mark=search_messages(service,query)
16+
print(f"Matched emails:{len(messages_to_mark)}")
1517
returnservice.users().messages().batchModify(
1618
userId='me',
1719
body={

‎general/gmail-api/read_emails.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ def read_message(service, message):
134134
service=gmail_authenticate()
135135
# get emails that match the query you specify from the command lines
136136
results=search_messages(service,sys.argv[1])
137+
print(f"Found{len(results)} results.")
137138
# for each email matched, read it (output plain/text to console & save HTML and attachments)
138139
formsginresults:
139140
read_message(service,msg)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp