Send email to NOT logged in member!

That would be awesome! Just need to see what I was doing wrong compared to what you and others have come up with. I really would appreciate it!

Here ya go!


import wixCrm from ‘wix-crm-backend’;
import wixData from ‘wix-data’;
let options = {
“suppressAuth”: true
}
// Function to get manager id using email address
function getCntId(email) {
return wixData.query(‘Members/PrivateMembersData’)
​.eq(‘loginEmail’, email)
.find(options)
.then( (results) => {
let Item = results.items[0];
let contactId = Item.contactId;
return contactId;
});
}
// Function to send email to manager
export function sendMail(email1,today1,com) {
// Set Manager email
let email = ’memberemail@domain.com’;
// Get manager id using email address
getCntId(email)
.then( (consumer) => {
// Send email to manager
wixCrm.emailContact(‘Testemail’, consumer, {
variables: {
“name”: email1,
“date”: today1,
“comments”: com
}}
);
});

@nino : BTW… this sends the email to a specific member, our bar manager, but you could probably modify it to pass it an email address too.