Receive email in admin inbox or outbox?

Hi Guys,

I have created a triggered email via wix code.

I have created a form for registered members. After filling the form a email is sent to the user of the information he has just submitted. However, i want another email to be sent to admin. I tried using CRM and specify userid but i guess its not working that way. I dont wish to use
sendgrid or other 3rd party.

I have integrated my gsuite and email but that does not help in this case.

Can someone help me how to do?

Try to call wixCRM.emailContact(“emailID”, contactId) twice, one by one:
first time with userId, then second one with adminId.

This function returns a promise, so you’ll probably need to add “await”

Hi Viktoria, I had tried but i was not successful. I am not a proper coder… On the same page I have code for sending the current registered user which is working fine. But for CRM, I couldnt.

So I did this:

import wixCRM from ‘wix-crm’;

$w.onReady( function () {
$w(“#dataset1”).onAfterSave( () => {
let userID = “59b97ad5-4a49-4213-667d2e2be188”; // this is the user id of the

wixCRM.emailContact(‘RbCoDA’, userID, {
variables: {
name: ,
p1addressline1: ,
p1pincode: ,
p1addressline2: ,
p2addressline1: ,
p2state: ,
purpose: ,
p2addressline2: ,
p1placemark: ,
p1fathername: ,
message: ,
p2name: ,
title: ,
p2placemark: ,
p2pincode: ,
p2fathername: ,
p1state:
}});

export function button1_click_1() {
$w(“#dataset1”).save();
}

Can you tell me how to do this correctly?

Just copy your function that sends email to the user (wixCrm.emailContact) and paste it right below this function (still in $w(" #dataset1 ").onAfterSave() scope).

Create a new variable under the userId variable (let adminId = “”);

Then in the second function (that you just pasted) change userId for adminId;

So the final code should be like this but i see “unexpected token error”.

You only can make imports on top of your document. Pay attention, that I suggested to paste your second function in $w(" #dataset1 #dataset1 ").onAfterSave() scope.
For more info on scopes in JavaScript: https://developer.mozilla.org/en-US/docs/Glossary/Scope

Also you can’t have two onReady functions on one page.
Please, read more here: https://www.wix.com/corvid/reference/$w.html#onReady

You can also try to hire Wix Expert on Wix Arena (Web Development section): https://www.wix.com/arena