Create E-Mail from Dataview(js)

Hi,

What i’ve done before

I am managing specific persons in my vault by creating a single note with yaml metadata for each person. Each note contains a field for the person’s e-mail.
I have written a dataviewjs, that lists all the persons, matching a specific criteria.

What I’m trying to do

Now, I’d like to create a single e-mail where the to field contains all the emails I have queried with my dataviewjs script. (Optionally i’d like to fill the cc field with the emails from a query matching different criteria)

I have seen some scripts in javascript, but i’m not sure i can apply those to dataviewjs.

I have search this forum, but couldn’t find a post with a similar use case.
Would this be in general possible? If so, how?

Thanks in advance,
BR Michael

I export the dataview view to Google Sheets (somebody could suggest a method if your email is hosted elsewhere: could always create a Google account and email to you own email provider and tidy up before sending again) and then use a script to send.

Example here:

Thanks for the reply. Google is not an option for me, due to privacy concerns.

I already did it once by exporting the table to CSV, reimporting to Excel and used the Series-Feature there to automatically generate all the e-mails in my Outlook mailbox. But that involved a lot of steps and was more work, than just creating the e-mails by hand. I was hoping to get a short snippet, that creates the e-mail automatically.

It seems like you’ve got the queries needed to produce the information you want to use, so couldn’t you simply transfer all of that into a dedicated note, and then use copy-paste for the three fields of interests:

  • To:-field
  • Cc: - field
  • Text of email?

If you use code blocks to some extent, you could even have the copy to clipboard readily available next to the addresses.

1 Like

Hi,

sorry for beeing pesimistic, but that still sounds like too much click-work to do. I was hoping for some automation. But that’s fine. Currently, i just do it manually. For such few people the task is doable. The problem could be if the person list grows. But then maybe i consider another tool.

if even then you need to use the Templater plugin to get your emails. dataview(js) is not suitable for tasks like that. it only is used to view data inside your vault.
so you need a js script that doesn’t use a 3rd party package that templater doesn’t support to scrape your emails and create a file for each email(threat) and have it link all related/replies together.
in the end the result should look something like


---
date: 2023-03-07 (that format is important)
subject:: “text”
---
prev:: [[answered to email]]
sender:: [[[email protected]]]
cc:: [[[email protected]]], [[[email protected]]], [[[email protected]]]
attachments:: [[link to file]]

  • text paragraph 1
  • text paragraph 2
  • text paragraph 3
  • text paragraph n

if you have it like that for each email, then you will be able to use Dataview to query the emails and show them inside the related persons notes.
but i can’t help you with how the templater code has to look like and how to scrape your emails because i have not the sligtest clue how to do js code that is longer than 10 dataviewjs lines.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.