Search.../

emailMember( )

Sends a triggered email to a site member.

Description

The emailMember() function returns a Promise that resolves when the triggered email is sent to the specified site member.

Note: This function replaces the deprecated wixUsersBackend.emailUser(). The deprecated function will continue to work, but it will not receive updates. To keep any existing code compatible with future changes, see the migration instructions.

To learn more about triggered emails, see:

Before using the emailMember() function, you need to set up at least 1 triggered email.

Specify which email to send by passing the email's ID in the emailId parameter.

Specify which member the email is sent to by passing the member's ID in the memberId parameter.

If the specified triggered email contains variables, you can pass values for those variables using the optional options parameter. You pass a variables object which contains the values to be inserted into your email in place of the variables defined in that email. The values passed must be strings. If variables does not contain a key:value pair for a variable in your triggered email, the fallback value defined when creating your triggered email is inserted in place of the variable.

Notes:

  • The statistics for Triggered Emails are based on every time an email is sent, including test emails that you send to yourself. This is different from the statistics for Email Marketing that are based on emails sent to unique contacts. Therefore, the statistics for Triggered Emails may seem inflated compared to Email Marketing statistics.
  • Triggered Emails generates a code snippet for each of your email templates. The generated code includes the email's ID and keys for all the email's variable names. You can copy and paste the snippet into your code. Then, you need to define values for the memberId property and for each variable key. To learn how to use the generated snippet in your code, see How to Send a Triggered Email with Code.

Syntax

function emailMember(emailId: string, memberId: string, [options: TriggeredEmailOptions]): Promise<void>

emailMember Parameters

NAME
TYPE
DESCRIPTION
emailId
string

Email ID of the triggered email to send.

memberId
string

ID of the member to send the email to.

options
Optional
TriggeredEmailOptions

Variable values to insert into the email.

Returns

Fulfilled - When the email is sent. Rejected - Error message.

Return Type:

Promise<void>

Was this helpful?

Send a triggered email to a member

Copy Code
1import { Permissions, webMethod } from 'wix-web-module';
2import { triggeredEmails } from 'wix-crm-backend';
3
4export const myEmailMemberFunction = webMethod(Permissions.Anyone, () => {
5 const emailId = "thanks_for_joining";
6 const memberId = "78ad23e2-fd34-5a14-9807-d8c2485d1f36";
7 const options = {
8 variables: {
9 firstName: "Jane",
10 lastName: "Member"
11 }
12 }
13
14 return triggeredEmails.emailMember(emailId, memberId, options)
15 .then(() => {
16 console.log("Email was sent to member");
17 })
18 .catch((error) => {
19 console.error(error);
20 });
21});