I really hope someone can help me figure out why I am not sent a notice when a new form is submitted. My Reply-to Email address is set up. The sender receives an email, but I am not copied on the email or otherwise notified that the form was submitted.
Can you help?
Here’s my code:
//MESSAGE FORM
$w.onReady(function () {
$w("#dataset25").onAfterSave(() => {
if (wixUsers.currentUser.loggedIn) {
const userId = wixUsers.currentUser.id;
wixUsers.emailUser("MessageAutoReply", userId, {
variables: {
"firstName": $w("#firstName").value,
"senderEmail": $w("#senderEmail").value,
"sendDate": $w("#sendDate").value,
"recipientEmail": $w("#primaryRecipient").value,
"EmailCC1": $w("#cc1Email").value,
"EmailCC2": $w("#cc2Email").value,
"EmailCC3": $w("#cc3Email").value,
"message": $w("#message").value
}
})
.then(() => {
// do something after the email was sent successfully
})
.catch((err) => {
// handle error that prevented the email from being sent
});
}
});
});
Hi Juanita,
I don’t think you’re supposed to get copied on emails sent to users via the emailUser API (the documentation doesn’t say that it does that).
BTW, the “reply-to” address is only used if/when the user that got emailed hits “reply” on that mail.
Thanks for the response Ofer! I guess you’re right! Do you have any simple suggestions (other than SendGrid) for setting up an automatic Notifier? Something easy, like JotForms offers . . .
One option is to send the same message to your user ID, with another call to emailUser
Could you tell me what the code would be for that, and where to put it?
You want the 2 emails sent at the same point, so do 2 “emailUser” calls, one after the other, with a different “userId” parameter.
Something like:
wixUsers.emailUser(“MessageAutoReply”, userId, …)
wixUsers.emailUser(“MessageAutoReply”, MY_USER_ID, …)
Thanks, Ofer, but I get an error when I try this:
//MESSAGE FORM
$w.onReady(function () {
$w("#dataset25").onAfterSave(() => {
if (wixUsers.currentUser.loggedIn) {
const userId = wixUsers.currentUser.id;
wixUsers.emailUser("MessageAutoReply", userId,
wixUsers.emailUser("MessageAutoReply", 07c93155-bfcc-4031-a5db-3d958dd83cd0, ...){
variables: {
"firstName": $w("#firstName").value,
"senderEmail": $w("#emailSender").value,
"sendDate": $w("#sendDate").value,
"recipientEmail": $w("#emailPrimaryRecipient").value,
"EmailCC1": $w("#cc1Email").value,
"EmailCC2": $w("#cc2Email").value,
"EmailCC3": $w("#cc3Email").value,
"subject": $w("#subject").value,
"message": $w("#message").value
}
})
.then(() => {
// do something after the email was sent successfully
})
.catch((err) => {
// handle error that prevented the email from being sent
});
}
});
});
I decided to add a SendGrid notification.