Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ m.body() # Cleaned text (no quotes/signatures)
m.html() # HTML body (falls back to text wrapped in <pre>)

# View message with headers (as dict or plain text)
view_msg(m.id) # Returns dict with headers + body
view_msg(m.id, as_json=False) # Returns formatted text
view_email(m.id) # Returns dict with headers + body
view_email(m.id, as_json=False) # Returns formatted text

# View full thread
view_thread(t.id) # Dict of msgid -> msg dict
Expand Down
2 changes: 1 addition & 1 deletion solvemail/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def g():
if _g is None: raise AttributeError('Call solvemail.init(...) first')
return _g

def solvemail_tools(): return '&`[search_threads, search_msgs, thread, draft, drafts, labels, label, find_labels, profile, send, reply_draft, reply_to_thread, create_label, trash_msgs, view_inbox, view_inbox_threads, view_msg, view_thread, batch_delete, batch_label, create_draft, message, send_drafts, report_spam]`'
def solvemail_tools(): return '&`[search_threads, search_msgs, thread, draft, drafts, labels, label, find_labels, profile, send, reply_draft, reply_to_thread, create_label, trash_msgs, view_inbox, view_inbox_threads, view_email, view_thread, batch_delete, batch_label, create_draft, message, send_drafts, report_spam]`'

def wait_secs(secs: float = 1.0):
"Pause for `secs` seconds; use if rate limited"
Expand Down
6 changes: 3 additions & 3 deletions solvemail/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -710,7 +710,7 @@ def view_inbox_threads(self, max_threads=20, unread=False):
threads = self.search_threads(q, max_results=max_threads)
return self.get_threads(threads, fmt='full')

def view_msgs(self,
def view_emails(self,
ids:list, # Message ids to fetch
fmt:str='metadata' # Format: 'full', 'metadata', or 'minimal'
):
Expand All @@ -727,7 +727,7 @@ def view_threads(self,
return [{'id': t.id, 'msgs': [{'id': m.id, 'frm': m.frm, 'to': m.to, 'subject': m.subj,
'snippet': m.snip, 'labels': list(m.label_ids)} for m in t.msgs()]} for t in threads]

def view_msg(self,
def view_email(self,
id:str, # Message id
clean:bool=True, # Strip reply quotations and signatures?
as_text:bool=True, # Return text body (vs HTML)?
Expand Down Expand Up @@ -756,7 +756,7 @@ def view_thread(self,
):
"View thread messages with optional headers/metadata. This is primarily for LLM and programmatic use. Humans use `thread()` to get HTML view."
t = self.thread(id, fmt='full')
res = {m.id: self.view_msg(m.id, clean=clean, as_text=as_text, as_json=as_json) for m in t.msgs()}
res = {m.id: self.view_email(m.id, clean=clean, as_text=as_text, as_json=as_json) for m in t.msgs()}
if as_json: return res
return ('\n\n' + '='*60 + '\n\n').join(res.values())