Pull up Gmail history for a particular contact

If you store contacts in Grist, and use Gmail to email them, there is a simple way to create a formula that will open Gmail to a list of conversations with that contact.

  • Basic Formula

    If the contact’s email address is in the column $Email, then write a formula like this:

    from urllib.parse import quote_plus
    "https://mail.google.com/mail/#search/" + quote_plus($Email)
    

    This will produce a column of clickable links that look like here https://mail.google.com/mail/...

  • Prettier Version

    You can make this link prettier as follow. Add the link text, like “Search Gmail” to the formula, like so:

    from urllib.parse import quote_plus
    "Search Gmail https://mail.google.com/mail/#search/" + quote_plus($Email)
    

    Then change the column type to Text, and select HyperLink under Cell Format:

    HyperLink Cell Format

    Now you’ll see clickable links, but they’ll show up as Search Gmail.

  • Example in action

    To see this example in action, visit our Lightweight CRM template:

2 Likes

What is the formula to open up Gmail and compose a new email?

And what would the structure be to include a specific message?

Thanks.

See this post, which I think answers your exact question! Prefill emails - Grist Help Center

1 Like

Thanks @dmitry-grist !

How might I go about having a table of standard replies that could be then selected using the function:

from urllib.parse import quote
return "Compose mailto:%s?cc=sales@example.com&subject=%s&body=%s" % (
  quote($Email), quote($Subject), quote($Body))

Thanks again

Good question. Here is a modified version of the “Email Contacts” template, which lets you configure and use email templates: https://templates.getgrist.com/3HfynRQwpHPy~w8dL9EbEhHSw28tVB4tYQx~26/Email-Contacts/p/2

You’ll see there is a separate table of templates, identified by name. The content of the templates has text like this: Dear {Contact_Name}. Then the constructed body of the particular email fills it in using the Python format function, like this:

$Template.Body.format(
  Contact_Name=$Contact_Name,
  Team=$Team,
  Email=$Email,
)

Here’s a screenshot:

1 Like