You have two lists — email snippets and event titles — and you want to land them in your own inbox as a single digest. How would you turn a list of strings into the body of an email?
"\n".join(list) to stitch lines with newlines? And then concatenate two joined blocks with headings in between?
That's the shape. join is the standard string-to-body converter. Build up the body line by line with newline separators, then print before sending:
body = "Emails:\n" + "\n".join(snips)
body += "\n\nEvents:\n" + "\n".join(sums)
print(body)And the send call passes the body plus a subject plus a to — any tricks around sending to yourself versus sending to someone else?
For self-sends, the GMAIL_SEND_EMAIL action accepts "to": "me" or your own address. Keep the send scoped to yourself for anything experimental — writes that leave your account are permanent. Full function:
def send_digest_email() -> str:
emails = toolset.execute_action(Action.GMAIL_FETCH_EMAILS, {"max_results": 5})
events = toolset.execute_action(Action.GOOGLECALENDAR_FIND_EVENT, {"query": ""})
snips = [m.get("snippet", "") for m in emails.get("messages", [])]
sums = [e.get("summary", "") for e in events.get("items", [])]
body = "Emails:\n" + "\n".join(snips) + "\n\nEvents:\n" + "\n".join(sums)
toolset.execute_action(Action.GMAIL_SEND_EMAIL, {"to": "me", "subject": "Digest", "body": body})
print(f"Digest length: {len(body)} chars")
return bodyReturning the body — why not the send result or just True?
Returning the body lets the caller log exactly what went out, diff against last week's digest, or re-send without re-fetching. The server response for a send is usually a message id, which is useful only if you plan to modify the sent mail later. Most digest callers never need that id.
So this is the shape for every write that ends in "send" or "publish" — read the data, format it, fire the write, hand back what was sent?
Read, format, send, return. One function, three API interactions, one mail you can now schedule to yourself every morning. That's the point of automation.
TL;DR: Fetch, format with "\n".join, send, return the body you sent.
f"Emails:\n{...}\n\nEvents:\n{...}"GMAIL_SEND_EMAIL with to: "me"to: "me"| Target | Risk |
|---|---|
"me" / self | Always safe — landed in your own inbox |
| Real contact | Permanent — no "undo send" from Python |
| List of addresses | Loop sends scale risk linearly |
Scope every new send to yourself until the function has run cleanly on at least three test digests.
You have two lists — email snippets and event titles — and you want to land them in your own inbox as a single digest. How would you turn a list of strings into the body of an email?
"\n".join(list) to stitch lines with newlines? And then concatenate two joined blocks with headings in between?
That's the shape. join is the standard string-to-body converter. Build up the body line by line with newline separators, then print before sending:
body = "Emails:\n" + "\n".join(snips)
body += "\n\nEvents:\n" + "\n".join(sums)
print(body)And the send call passes the body plus a subject plus a to — any tricks around sending to yourself versus sending to someone else?
For self-sends, the GMAIL_SEND_EMAIL action accepts "to": "me" or your own address. Keep the send scoped to yourself for anything experimental — writes that leave your account are permanent. Full function:
def send_digest_email() -> str:
emails = toolset.execute_action(Action.GMAIL_FETCH_EMAILS, {"max_results": 5})
events = toolset.execute_action(Action.GOOGLECALENDAR_FIND_EVENT, {"query": ""})
snips = [m.get("snippet", "") for m in emails.get("messages", [])]
sums = [e.get("summary", "") for e in events.get("items", [])]
body = "Emails:\n" + "\n".join(snips) + "\n\nEvents:\n" + "\n".join(sums)
toolset.execute_action(Action.GMAIL_SEND_EMAIL, {"to": "me", "subject": "Digest", "body": body})
print(f"Digest length: {len(body)} chars")
return bodyReturning the body — why not the send result or just True?
Returning the body lets the caller log exactly what went out, diff against last week's digest, or re-send without re-fetching. The server response for a send is usually a message id, which is useful only if you plan to modify the sent mail later. Most digest callers never need that id.
So this is the shape for every write that ends in "send" or "publish" — read the data, format it, fire the write, hand back what was sent?
Read, format, send, return. One function, three API interactions, one mail you can now schedule to yourself every morning. That's the point of automation.
TL;DR: Fetch, format with "\n".join, send, return the body you sent.
f"Emails:\n{...}\n\nEvents:\n{...}"GMAIL_SEND_EMAIL with to: "me"to: "me"| Target | Risk |
|---|---|
"me" / self | Always safe — landed in your own inbox |
| Real contact | Permanent — no "undo send" from Python |
| List of addresses | Loop sends scale risk linearly |
Scope every new send to yourself until the function has run cleanly on at least three test digests.
Create a free account to get started. Paid plans unlock all tracks.