Create Email

Summary

The CREATE EMAIL command creates an email domain object.

Syntax

create email [if not exists] <email_name> as ([parameter_list]);

Parameters

Parameter
Parameter List
Description
[if not exists] (Optional) Create the email object only if the email name does not currently exist in Connect. Suppresses an XSQL error when an email name clash occurs.
<email_name> (Required) The name of the email object.
[parameter_list] "To" = <list of email addresses> (Required) The comma separated list of recipients of the email.
"From" = <email address> (Optional) The sender of the email. Defaults to “xactly@connect_server_name”.
"Cc" = <list of email addresses> (Optional) The comma separated list of carbon copy recipients.
"Bcc" = <list of email addresses> (Optional) The comma separated list of blind carbon copy recipients.
"Subject" = <string> (Optional) The subject of the email.
"Body" = <string>      (Required) The body of the email. The body can be any text MIME type.
"BodyType" = <string> (Optional) The MIME type of the email body, for example ‘html’. Refer to the Internet Assigned Numbers Authority (IANA) web site for a complete list of text MIME types. The default is ‘plain’.
"ReplyTo" = <list of email addresses> (Optional) The email addresses to which any replies should be sent.
"Attachment#" = <string> or <result set>   (Optional) Attaches a file to the message. “#” is a positive integer value starting at 1 to identify each distinct file attachment. Multiple files can be attached to an email using “Attachment1”, “Attachment2”, “Attachment3”, etc.
"AttachmentName#" = <string> (Optional) Sets the name for the attachment. Attachment defaults to either the referenced file name or “Attachment#” if the attachment is an XSQL result set.
"AttachmentType#" = <string> (Optional) The MIME type of the attachment. Refer to the Internet Assigned Numbers Authority (IANA) web site for a complete list of text MIME types. The default is ‘plain’.

Details

String lists used with input parameters are all comma separated. Since some of the parameter names are reserved words, Xactly recommends surrounding each parameter in double-quotes (“). In cases when a parameter describes a list of string values, such as the “To” parameter, you can specify a result set with the first column of each row representing part of the string, e.g. “To” = (select addresses from delta.custom_table).

The email is not sent automatically after creating it using this command. Use the SEND EMAIL command.

Examples

Basic example. Send email to one recipient using Subject and Body parameters.

create email e1 as
("To"='abc@xactlycorp.com',
"Subject"='Testing 1,2,3',
"Body"='Hey! This is an email test.');

Example uses additional SMTP headers

create email e2 as ("To"='to1@test2.com, to2@test2.com',
Subject"='Testing 1,2,3',
"Body"='Another test',
"Cc"='cc1@test2.com, cc2@test2.com, cc3@test2.com',
"Bcc"='bcc1@test2.com, bcc2@test2.com',
"ReplyTo"='rt@test2.com, rt2@test2.com');

Create an email using all available parameters. Example shows two methods for creating file attachments.

create email if not exists e_process_ended as
("To" = 'some_distro_list@acme.com',
"From" = 'donotreply@xactlycorp.com',
"Cc" = 'it@acme.com',
"Bcc" = 'boss@acme.com',
"Subject" = 'Xactly: Upload orders has completed',
"Body" = 'Attachment1 was generated using a SELECT statement. Attachment2 was read from the server file system.',
"BodyType" = 'plain',
"ReplyTo" = 'donotreply@xactlycorp.com',
"Attachment1" = (select order_code, item_code, error_message from staging.order_item_validation_error),
"AttachmentName1" = 'validation_errors_'||ToDate(Now())||'.csv',
"AttachmentType1" = 'plain',
"Attachment2" = ('/extracts/participants.csv'),
"AttachmentType2" = 'plain');

Related Commands

ALTER EMAIL

DROP EMAIL

SEND EMAIL