Send an Email

To simplify job creation, Docoon REST API provides to you a specific resource per media. For Email jobs only the resource is called “EmailJobs”.

We will review how to send quickly an Email with one recipient or many recipients. We will also review the Email advanced parameters and the text personnalisation of the email body.

When the Email job request is accepted, you will get a jobNumber, it means a job was accepted and was put in the appropriate queue (depending on your priority defined in your contract), we will send the message to each recipient as soon as possible depending of the current traffic.

When the job is finished, you will be able to check the transmission status of each recipient, check “Get transmission reports” easy worflow for more information.

Send Email request informations

Name: /EmailJobs
Type: POST

Headers:

Name Value
Authorization Value : Authorization token check : Connect to REST API
Content-Type Value : application/json

 

Parameters list:

Parameter Type Description
JobType String JobType you want to use (‘Email’ for Email Sending).
TrackingID String (Optional) String of your choice, as a reference for the job (shown in the summary and in your billing).
LaunchType Integer (Optional) Choose your type of sending 0 = Send your message , 1 = Do a proof , 2 = Do a preview.
ScheduledStartTime String (Optional) Choose a date to schedule your job.Example : ‘2017-06-08T03:50:25.355Z’
EmailBody FileReference A valid HTML or TXT file that is the body of your email.
EmailAltBody FileReference (Optional) A TXT file that is the alternative body of your email.
Attachments List of FileReference

(Optional) List here the FileReference of files you want to attached to your email.

You can also list non-hosted files and images that are referenced in the email body. Docoon system will take care of hosting these files and images and will modify the email body to point to these hosted files and images. The name of the image should be the same as the name in the email body.

AdhocRecipients List of AdhocRecipients (Optional can be replace by List File)
List of AdhocRecipients: List of the recipients for the sending, see below for the AdhocRecipients Structure.
Lists List of FileReference (Optional can be replace by AdhocRecipients)
List of FileReference : Used for the recipient list.
List format: .xlsx, .xls, .csv, .tab.
your list should at least contained the phone number in the first column (default setting), then it is up to you to fill the other column.
Parameter EmailParameter Advanced parameters for Email sending (see below).

 

Structure details of AdhocRecipients

This Object is used to list your recipient in the “AdhocRecipients”

Parameter Type Description
Name String Name or Id of your recipient.
Address String Address/Phone number of your recipient.
OptionalFields List of String List of additionnal information of your recipient (Last Name, Birth date, Country, …) .
The first 5 items of the list will be included in the reports.
It is also possible to use these elements to personalize the messages.
If you want to add the first item of this list use ‘BCF3 (then ‘BCF4, 5 etc..).
`BCF1 = Value inserted into the field “Address” and `BCF2 = Value inserted into the field “Name”.

 

Structure details of FileReference

The object File Reference is used for both list and documents, The structure is the same but you have to select the right “Type” depending of your document.

Parameter Type Description
Name String Name of the file with extension (abc.txt).
Content String FileEncoded in BASE64
Hosted Boolean (optional) True: if the file is hosted in your hosted document (Docoon hosted document), False: if not.
MimeType String (Optional) If the file’s MIME type is defined, it will be used for sending email. Else, the system will associate a MIME type based on the file extension.
Type Integer Select your document type :
0 = List
1 = Document
2 = Body (specific email)
3 = AltBody (specific email)
4 = Attachment (specific email)
Send Basic Email
{
	"JobType": "Email",
	"TrackingId": "Send basic Email",
	"EmailBody": {
		"Name": "body.html",
		"Content": "PGh0bWw+DQo8aGVhZGVyPg0KPG1ldGEgY2hhcnNldD0iVVRGLTgiPg0KPC9oZWFkZXI+DQo8Ym9keT4NClRoaXMgaXMgYW4gZW1haWwgdGVzdCBmcm9tIE9keXNzZXkgTWVzc2FnaW5nLg0KPC9ib2R5Pg0KPC9odG1sPg==",
		"Type":2
	},
	"AdhocRecipients" : [
		{
			"Address":"usern@gmail.com",
			"Name":"John",
			"OptionalFields": [
				"My Company",
				"BirthDate"
			]
		}
	],
	"Parameter": {
		"Media" : 5,
		"Subject": "My Email subject",
		"ReplyTo":"support@myCompany.com"
	}
}

Email advanced parameters description

In addition to the parameters presented above, there are advanced parameters allowing to configure specific parameters to Email sending (subject, reply-to, from address, …).

Parameter Type Description
Media Integer Type of media used
5: Email
Subject String Subject of the email. This parameters is require for each email sending.
ReplyTo String Email address used by the recipient to reply at your email.
From String The email from address with the alias.
You can use the fallowing form => “alias” <test@ods2.net>.
Docoon main sending domain is ods2.net, you can’t overload this domain. If you want to use your own domain please contact us.
ActivateAutoPull Boolean This feature allows you to automatically host your attachments on the Docoon system and insert them as a link in the email body.
If you want to use attachments larger than 5 MB, we recommend that you use this option.
true : add all attachment as link.
ActivateEmbeddedImageInHTML Boolean When activating that option, images in your HTML are added as attachment, will be hosted and included in your email.
true: include image into email body.
ActivateTracking Boolean This feature allows you to track email activity (openning action, click action, ..), you can find the statistics on the customer portal.
true : activate tracking.
TrackingType Integer (Optional) Type of tracking used for this job.
There is 3 tracking types :
0 = Open and Clic Tracking (default value)
1 = Open Tracking Only
2 = Clic Tracking Only
Use advanced parameters
{
	"JobType": "Email",
	"TrackingId": "Send Email with advanced parameters",
	"EmailBody": {
		"Name": "body.html",
		"Content": "PGh0bWw+DQo8aGVhZGVyPg0KPG1ldGEgY2hhcnNldD0iVVRGLTgiPg0KPC9oZWFkZXI+DQo8Ym9keT4NClRoaXMgaXMgYW4gZW1haWwgdGVzdCBmcm9tIE9keXNzZXkgTWVzc2FnaW5nLg0KPGJyLz4NCjxhIGhyZWY9Imh0dHA6Ly93d3cub2R5c3NleS1tZXNzYWdpbmcuY29tIj5UaGlzIGlzIGEgbGluayB0byB0ZXN0IHRoZSB0cmFja2luZyBvcHRpb248L2E+DQo8L2JvZHk+DQo8L2h0bWw+",
		"Type":2
	},
	"AdhocRecipients": [
		{
			"Address":"usern@gmail.com",
			"Name":"John",
			"OptionalFields": [
				"My Company",
				"BirthDate"
			]
		}
	],
	"Attachments": [
		{
			"Name": "Attachment1.txt",
			"Content": "VGhpcyBpcyBhbiBhdHRhY2hlbWVudCBmaWxl",
			"Type":4
		}
	],
	"Parameter": {
		"Media" : 5,
		"Subject": "My Email subject",
		"ReplyTo":"support@myCompany.com",
		"From":"\"Mycompany\" <MyCompany@ods2.net>",
		"ActivateAutoPull": true,
		"ActivateTracking": true
	}
}

Send an Email using a file list

You can also use a file list for your recipient. You will have to replace the “AdhocRecipients” list by a “Lists” of File Reference (see the structure above). List format accepted : .xlsx, .xls, .csv, .tab.

By Default, the email address should be in the first column of the first (and only) sheets of your file.
The other columns can be used for personalizations.

Use a file list
{
	"JobType": "Email",
	"TrackingId": "Send Email with file list",
	"EmailBody": {
		"Name": "body.html",
		"Content": "PGh0bWw+DQo8aGVhZGVyPg0KPG1ldGEgY2hhcnNldD0iVVRGLTgiPg0KPC9oZWFkZXI+DQo8Ym9keT4NClRoaXMgaXMgYW4gZW1haWwgdGVzdCBmcm9tIE9keXNzZXkgTWVzc2FnaW5nLg0KPC9ib2R5Pg0KPC9odG1sPg==",
		"Type":2
	},
	"Lists": [
		{
			"Name": "test.tab",
			"Type":0,
			"Content": "dXNlcm5AZ21haWwuY29tCUpvaG4JTXkgQ29tcGFueQlCaXJ0aERhdGU="
		}
	],
	"Parameter": {
		"Media" : 5,
		"Subject": "My Email subject",
		"ReplyTo":"support@myCompany.com"
	}
}

Sucessful response

Status: 200 : OK

Parameters list:

Parameter Type Description
JobNumber int ID of the job created
Sucessful response
{
  "JobNumber": 44608862
}

Error response

Status: 400: Bad request

Parameter Type Description
Message String Specification of the problem.
ModelState list of job List of job (String error).
Error response
{
  "Message": "The request is invalid.",
  "ModelState": {
    "job": [
      "An error has occurred."
    ]
  }
}

More Usage Examples

Message personalization

You can personalize your Email body using “`BCFX” values. X being the position of the data you want to send.
For Adhoc sending, `BCF1 is the email address,`BCF2 is the Name, `BCF3 the first optional field, `BCF4 the second optional field, …
For List sending, the number is the position in the column. `BCF1 is the first column (usually the email address), `BCF2 is the second column, …

In the following AdHoc Sample,
We use the text : “Hi `BCF2, Are you from `BCF3 ?”
the resulting test of the 1st Recipient will be : “Hi Dupont, Are you from Company A ?”.
the resulting test of the 2nd Recipient will be : “Hi James, Are you from Company B ?”.

Personalization using Adhoc
{
	"JobType": "Email",
	"TrackingId": "Send Email with personalisation",
	"EmailBody": {
		"Name": "body.html",
		"Content": "PGh0bWw+DQo8aGVhZGVyPg0KPG1ldGEgY2hhcnNldD0iVVRGLTgiPg0KPC9oZWFkZXI+DQo8Ym9keT4NCkhpIGBCQ0YyLCBBcmUgeW91IGZyb20gYEJDRjMgPw0KPC9ib2R5Pg0KPC9odG1sPg==",
		"Type":2
	},
	"AdhocRecipients": [
		{
			"Address":"usern@gmail.com",
			"Name":"Dupont",
			"OptionalFields": [
				"Company A",
				"BirthDate"
			]
		},
		{
			"Address":"usern@gmail.com",
			"Name":"James",
			"OptionalFields":[
				"Company B",
				"BirthDate"
			]
		}
	],
	"Parameter":{
		"Media" : 5,
		"Subject": "My Email subject",
		"ReplyTo":"support@myCompany.com"
	}
}

Scheduled job

Use the “ScheduledStartTime” value to delay your sending.
In our example you will send a message the 1st of January 2019.

Scheduled job
{
	"JobType": "Email",
	"TrackingId": "Send a scheduled Email",
	"ScheduledStartTime": "2019-01-01T00:00:00.688Z", 
	"EmailBody": {
		"Name": "body.html",
		"Content": "PGh0bWw+DQo8aGVhZGVyPg0KPG1ldGEgY2hhcnNldD0iVVRGLTgiPg0KPC9oZWFkZXI+DQo8Ym9keT4NClRoaXMgaXMgYW4gZW1haWwgdGVzdCBmcm9tIE9keXNzZXkgTWVzc2FnaW5nLg0KPC9ib2R5Pg0KPC9odG1sPg==",
		"Type":2
	},
	"AdhocRecipients" : [
		{
			"Address":"usern@gmail.com",
			"Name":"John",
			"OptionalFields": [
				"My Company",
				"BirthDate"
			]
		}
	],
	"Parameter": {
		"Media" : 5,
		"Subject": "My Email subject",
		"ReplyTo":"support@myCompany.com"
	}
}

Use Email Template created from customer portal

You can use a template email created on the email body editor (on customer portal) as an email body. To do that, on the FileReference of the email body you have to specified the name of the template into the field “Name” and put the field “Hosted” to true.

Use email body template
{
	"JobType": "Email",
	"TrackingId": "Send a scheduled Email",
	"ScheduledStartTime": "2019-01-01T00:00:00.688Z", 
	"EmailBody": {
		"Name": "TemplateName",
		"Hosted": True,
		"Type":2
	},
	"AdhocRecipients" : [
		{
			"Address":"usern@gmail.com",
			"Name":"John",
			"OptionalFields": [
				"My Company",
				"BirthDate"
			]
		}
	],
	"Parameter": {
		"Media" : 5,
		"Subject": "My Email subject",
		"ReplyTo":"support@myCompany.com"
	}
}