createEmailMessage method

It is a method to create an email without sending it. The email is sent using another method — createCampaign.

Please note that the maximum size of an email message is 8mb.

Principle of use

Syntax and URL to call the method
createEmailMessage (string sender_name, string sender_email,
string subject, string body, int list_id [, string tag, string array attachments,
string lang, string wrap_type,
string text_body, bool generate_text, string categories])
https://api.selzy.com/en/api/createEmailMessage?format=json&api_key=KEY&sender_name=FROMNAME&sender_email=
FROMMAIL&subject=SUBJECT&body=HTMLBODY &list_id=X&tag=
TAG&attachements=FILESARRAY&lang=LANG&wrap_type=STRING&text_body=
TEXTBODY&generate_text=GENERATETEXT &categories=CATEGORIES
Arguments
api_key * API access key.
sender_name * Sender's name. It is an optional string that does not match the email address (the sender_email argument).
sender_email * Sender's email address. This email must be checked (to do this, you need to manually create at least one email with this return address via the web interface, then click on the "send the confirmation request" link and follow the link from the email).
subject * String with the letter subject. It may include substitution fields. The parameter is optional if template_id is indicated.
body * Text of the letter in the HTML format with the possibility to add substitution fields.
You can add an image transmitting it as an attachment file (see the description of the attachments argument).
If you transfer the entire HTML text, test such letters additionally as headers outside the body may be modified.
The parameter is optional if template_id or system_template_id is indicated.
list_id * Code of the list on which the mailing will be sent. Codes of all lists can be obtained by calling getLists. The letter may be sent only on a single list. You need to create a new letter to send on another list.
text_body Text version of the template. It is absent by default. If you do not provide the text version along with the HTML version, you are recommended to set the generate_text parameter to 1 for automatic generation of the text part of the letter.
generate_text 0 or 1, 0 by default. A value of 1 means that the text part of the letter will be generated automatically based on the HTML part. If you do not provide the text version along with the HTML version, you are recommended to set the generate_text parameter to 1 for automatic generation of the text part of the letter.
If the text variant of the letter is provided using the text_body parameter, the generate_text parameter is ignored. Thus, if the generate_text value has been set to 1, the server's response will contain a warning.
raw_body It is intended to save the json structure of the block editor data structure (if the value is message_format = block) The parameter obtains only the JSON structure, otherwise it will not be transferred.
message_format It defines the manner of creating a letter: «block» — block editor, «raw_html» — html editor, «text» — text.
1. If you transfer the «text» value in this parameter and both the body and text_body parameters are filled, the body parameter will be ignored, and the letter will be created from the data, transferred in the text_body parameter.
2. If you transfer the «block» value in this parameter but do not specify raw_body, the letter will be saved as raw_html.
3. If you transfer the «block» value in this parameter, the body and raw_body parameters must be transferred so that you can save the message in the block editor format.
tag Tag. If it is set, the letter will not be sent on the entire list, but only to those recipients to whom the tag is assigned.
attachments Associative array of file attachments. The file name is specified as the key, and the binary content of the file (base64 cannot be used!) is specified as the value, for example: attachments[quotes.txt]=text%20file%content

Using a PHP script, the file contents can be obtained through the file_get_contents function. For example:

$api_query = array(....,"attachments[test.pdf]"=>file_get_contents('test.pdf'),...);

Attachments will be added to the message in the same order as they are listed. Inline images can be added to the text through adding them as attachments and referring to them in HTML as follows: img src="3_name.jpg". You need to substitute the ordinal number of the attachment instead of the number three, and the attachment name instead of name.jpg.

The attachment file must be only in Latin letters with the extension.

lang Two-letter language code for the string with the unsubscribe link that is added to each letter automatically.
If it is not specified, the language code from the API URL is used.
In addition to the string with the unsubscribe link, this language also affects the interface of the unsubscribe page. Languages en, it, ua and ru are fully supported, and in case of some other languages (da, de, es, fr, nl, pl, pt, tr), the string with a link will be translated, and the control interface will be in English.
template_id ID of the user letter template created before, on the basis of which a letter can be created. The value can be obtained using getTemplates or listTemplates. If you have transferred this parameter, you may skip the mandatory subject, body, as well as text_body and lang parameters. These values will be taken from the corresponding parameters of the template the id of which was specified.
If any of the above parameters is still transferred, the system will ignore the parameter that is taken from the template parameters, and the parameter explicitly transferred in this method will be used.
system_template_id ID of the system letter template created before, on the basis of which a letter can be created. The value can be obtained using getTemplates or listTemplates. If you have transferred this parameter, you may skip the mandatory subject, body, as well as text_body and lang parameters. These values will be taken from the corresponding parameters of the template the id of which was specified.
If any of the above parameters is still transferred, the system will ignore the parameter that is taken from the template parameters, and the parameter explicitly transferred in this method will be used.
If none of the template_id or system_template_id parameters is specified, templates will not be used to create the letter
wrap_type Alignment of the message text on the specified side. If the argument is missing, the text will not be aligned. It may have the following values: skip (do not apply), right (right alignment), left ((left alignment), center (center alignment).
categories Letter categories listed in the text form separated by commas.

 

Return value
JSON object with the single message_id field, which contains a unique message code – a positive 31-bit integer. It is used to send a message using the createCampaign method.
Example of the return value:

{"result":{"message_id":357088}}
{"error":"unchecked sender email","code":"invalid_arg","result":""}

Did we answer to your question?

2
4