Send Email with SendGrid NPM to Members in Multiple Reference Field

@yisrael-wix , I really appreciate the articles you’ve shared on using the sendGrid NPM interface. I have been able to use it successfully to send it to individual email addresses from input fields.

Here is what I really want to make happen:

  1. A member creates a post, “tagging” several other members

  2. The member hits the “post” button, inserting a new item into my “posts” database, and entering the references for the tagged members into that post’s multiple reference field labeled “tags”

  3. Either upon “post” button press or afterInsert, the email addresses of the post’s tagged members are used as “recipients” of my templated email.

1&2 already happen, and I have come up with a shortcut such that an email gets sent to each individual tagged member when the member is tagged (not after the user is finished crafting and submitting the post), and therefore entered into my database. However, this can cause problems because the user creating the post might accidentally tag someone and then remove them, or might end up canceling the post.

In addition, I want to be able to send a separate email to other site members who are interested in the topic being posted about, and I need to figure out how to send one email to an array of members based on their stored email addresses.

Please let me know if anything is unclear!