Getting Using Email Addresses
Contents
This topic describes several ways to get the e-mail address of a customer using Context Services blocks and using it in the To property of the Create Email block.
Getting a Customer Email Address
There are two ways to get a customer's e-mail address from the Context Services server:
- Use the Query Customer block. If the Customer ID is unknown, first follow steps 1 and 2 below. Then, follow the steps 3 and 4.
- Use the Identify Customer block. Follow step 1 and set the property Get Attributes to Yes. Then follow step 4 and change the ECMAScript expression to _data.EmailAddress=_data.CustomerData[0].EmailAddress
Identifying a Customer
- Identifying a Customer. A customer ID is necessary to use the Query Customer block. If the customer ID is unknown, you may use the Identify Customer block to get the Customer ID. In the example below, we are trying to identify a customer by the last name. The result of the request is stored in the CustomerData variable.
- Getting the Customer ID. An ECMAScript block is used to extract the Customer ID after identifying the customer. The variable CustomerID is used.
- Querying the customer profile.The CustomerID variable is used in a Query Customer block. The result (JSON) is put in the CustomerData variable.
With the default Context Services schema, EmailAddress is a field of the customer profile. The CustomerData content sample:
{"EmailAddress":"Roger.Rosen@genesyslab.com","FirstName":"Roger","PhoneNumber":["+1.219.12345678","+1.832.67890123"],"LastName":" Rosen ","customer_id":"00001a5GD0A80040"}
- Extracting the e-mail address field. You can then use a simple expression in an ECMAScript block to extract the e-mail address. The example below illustrates how to use Expression Builder to extract the e-mail address from the Core customer profile when using the default Context Services schema.
Using the E-mail Address in the To Field
In the Create Email block, when defining the To property, select the Type as Variable and select the variable that was previously used to save the e-mail address (data.EmailAddress) from above.
Using Variables Mapping for E-mail Addresses
With the Variables Mapping feature, getting an e-mail address is easy. When Customer ID is unknown:
- Set the Identify Customer/Get Attributes property to "Yes"
- Set the Identify Customer/Variables Mapping property to map the variable "EmailAddress" to the Context Services attribute "EmailAddress"
When Customer ID is known:
- Set the Query Customer/Variables Mapping property to map the variable "EmailAddress" to the Context Services attribute "EmailAddress"
No additional ECMAScript block is needed. The "EmailAddress" variable will automatically be assigned the customer's email address.