/obsidian-google-mail

Fetch emails to Obsidian (as markdown) from Gmail server

Primary LanguageTypeScript

Obsidian Google Mail

This plugin saves emails on Gmail as markdown notes. Use this plugin safely so you won't mess up your gmail account.

Application Scenarios

  1. Automatically save subsribed newsletter and takes note on it.
  2. You can email ideas to yourself and let the plugin collect them into vault.
2022-11-04.00.03.59.mov

Installation - I

Already have a credential : If you're using google api in other plugins you can simplely enable the Gmail api for that project, then you can reuse the credential.

Use my credential : I have a credential for 100 users and would like to know how much it's gonna cost for multiple users. Contact me so you don't need to go through this part. (thingnotok at gmail.com)

Create your own credential, it's free : Goto https://console.cloud.google.com/ to create the credential.

  • The detail steps with video can be found here

Installation - II

  1. Install this plugin manually or through BRAT

  2. Enable the plugin, and click option (or open the seting panel of this plugin)

  3. Click Setup button and Paste content from credential.json (from installation I)

  4. A web window should show up and ask you to login google with email access permission.

  5. The plugin will automatically query available labels in your Gmail account. Select the from/to labels to fetch.

    • From: Label to fetch from Gmail.
    • To: Fetched mail will be added with this label
  6. Assign a Folder to store all the collected email notes. (Default is "fetchedMail")

    • The plugin will create a folder if not exists.
    • A newsletter folder to use with DB Folder would be useful to organize your mail notes.
  7. Click the ribbon button on left side to fetch all the emails with that label.

Setup in Gmail

Labels: This plugin use label to decide which mail to fetch. So you need to use Gmail to assign the {From} label to those mails you want to fetch. The {From} label will be removed from the fetched mails, and {To} label will be added. These two labels should be mutually exclusive. I suggest to create a new label for {To}.

Filters:

  • You can add {From} label to mails manually when you review you inbox.
  • Or You can also setup filters to add the labels automatically.
    • Check the tutorial here.
    • Add the newletters so you can take notes on them
    • Add the mails you send to yourself, so you can achieve "email to obsidian".

Template

Check Template to learn how to setup a note template for email notes.

Security Issue

Background: Currently, the plugin will keep a .token.json file containing all the information required to access gmail account, so you don't have login everytime. But it also means that anyone with the file can do whatever he/she wants to your emails. In addition to the others, all plugins you use have access to this file, too.

This is actually a common issue for plugins trying to integrate other services. There are discussions about how to safely keep these security files. But it's not gonna easy for a pure local application.

What to do? For now, please don't use this plugin in public computers or shared vaults. Make sure no one can access the token file.

Another approach is that if you use this plugin for "newsletters" and "send to obsidian", then you can create a separate gmail account for them so those important business letters won't be afftected.

Other details

  • The mails are converted to markdown format. Some emails may seem weird.
    • Thanks to the contrubuters of Turndown.
    • I will add support to save email in plaintext format. Plaintext is suited for note-taking and avoid most of weidly large images in the note.

Thanks

The plugin originates from u/egauthier64's email-to-obsidian idea but is an approach based on Gmail server. For the Google API part, I would like to thank YukiGasai for his great work on Google series plugins for obsidian and I learn a lot from his implementation. Please check his awesome plugins here, they are extremely useful with google suite and obsidian: