# Receive email in admin inbox or outbox?

**URL:** <https://forum.wixstudio.com/t/receive-email-in-admin-inbox-or-outbox/21060>\
**Category:** Ask the community\
**Tags:** wix-members-area, code, question\
**Created:** [September 5, 2019, 6:41am UTC](https://forum.wixstudio.com/t/receive-email-in-admin-inbox-or-outbox/21060 "2019-09-05T06:41:52Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![info38197](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/info38197/32/11256_2.png) [@info38197](https://forum.wixstudio.com/u/info38197)\
**Post date:** [September 5, 2019, 6:41am UTC](https://forum.wixstudio.com/t/receive-email-in-admin-inbox-or-outbox/21060/1 "2019-09-05T06:41:52Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![viktoriian](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/viktoriian/32/14423_2.png) [@viktoriian](https://forum.wixstudio.com/u/viktoriian)\
**Post date:** [September 5, 2019, 8:20am UTC](https://forum.wixstudio.com/t/receive-email-in-admin-inbox-or-outbox/21060/2 "2019-09-05T08:20:44Z")

</div>

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”

---

<div class="post-metadata">

**Author:** ![info38197](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/info38197/32/11256_2.png) [@info38197](https://forum.wixstudio.com/u/info38197)\
**Post date:** [September 5, 2019, 11:55am UTC](https://forum.wixstudio.com/t/receive-email-in-admin-inbox-or-outbox/21060/3 "2019-09-05T11:55:02Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![viktoriian](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/viktoriian/32/14423_2.png) [@viktoriian](https://forum.wixstudio.com/u/viktoriian)\
**Post date:** [September 5, 2019, 12:06pm UTC](https://forum.wixstudio.com/t/receive-email-in-admin-inbox-or-outbox/21060/4 "2019-09-05T12:06:27Z")

</div>

Just copy your function that sends email to the user (wixCrm.emailContact) and paste it right below this function (still in $w(" [#dataset1](https://www.wix.com/corvid/forum/search/~num~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;

---

<div class="post-metadata">

**Author:** ![info38197](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/info38197/32/11256_2.png) [@info38197](https://forum.wixstudio.com/u/info38197)\
**Post date:** [September 5, 2019, 1:18pm UTC](https://forum.wixstudio.com/t/receive-email-in-admin-inbox-or-outbox/21060/5 "2019-09-05T13:18:45Z")

</div>

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

 ![](https://us1.discourse-cdn.com/wix/original/3X/4/5/45d6e987a177beaecfb573dd2529e2ce3257d22b.png)

---

<div class="post-metadata">

**Author:** ![viktoriian](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/viktoriian/32/14423_2.png) [@viktoriian](https://forum.wixstudio.com/u/viktoriian)\
**Post date:** [September 5, 2019, 1:31pm UTC](https://forum.wixstudio.com/t/receive-email-in-admin-inbox-or-outbox/21060/6 "2019-09-05T13:31:09Z")

</div>

You only can make imports on top of your document. Pay attention, that I suggested to paste your second function in $w(" [#dataset1](https://www.wix.com/corvid/forum/search/~num~dataset1) [#dataset1](https://www.wix.com/corvid/forum/search/~num~dataset1) ").onAfterSave() scope.  
For more info on scopes in JavaScript: [https://developer.mozilla.org/en-US/docs/Glossary/Scope](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](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](https://www.wix.com/arena)
