Inline

Purpose

To send the merge document in the body of the email.

HTTP Request URL

https://{zohoapis_domain}/writer/api/v1/documents/{{document_id}}/merge/email

Path Parameters

ParameterData TypeDescription
Mandatory Parameters
document_idStringSpecify a unique id for the writer document.

Body Parameters

ParameterData TypeDescription
Mandatory Parameters
output_formatStringPass the default value 'inline' to send the merged document in the body of the email.
subjectStringSpecify a subject to the email.
recipient_emailStringSpecify the receiver's email id.
You can provide the data in any one of the below formats
merge_dataJSONObjectPass a String value through 'data' key as JSON Array.
merge_data_csv_contentFileProvide the required csv content in your API request body.
merge_data_json_contentFileProvide the required json content in your API request body.
merge_data_csv_urlurlProvide the required csv url in your API request body.
merge_data_json_url urlProvide the required json url in your API request body.
Optional Parameters
cc_emailStringSpecify the Cc email id's (maximum upto 10) separated by comma.
bcc_emailStringSpecify the BCC email id's (maximum upto 10) separated by comma.
from_emailString

Specify the from address using which the merge document needs to be sent.

If the 'from_email' parameter is not passed (OR) the 'from address' is not configured in the Template's Mail Merge Settings, we will go ahead and use the Email ID of the current user who is sending the mail (by default).

common_attachmentsFile

Specify the attachments that needs to be sent to all the recipients in common.

Maximum files allowed: 3

Maximum file size allowed: 3MB

Supported file formats: docx / doc / rtf / pdf / zip / html / txt / png / jpeg / gif / jpg

unique_attachments

{
  "type": "field",
  "field_id": <field_id>
}

(OR)

{
   "type": "file",
   "folder_id":123456789,
   "filename_filter":
        {
           "type":"startswith/contains/is/endswith",
           "value": <field_id>
        },
}

Using this param, you can send a different or unique attachment to each recipient.

It can be sent in either one of the following ways;

1. Field Containing Attachment URLs - If you want to map the attachment file paths to a spreadsheet/CSV file.

(OR)

2. Folder Containing Attachments - If you want to map the attachment file paths to a particular folder.

from_nameStringSpecify the display name for your 'from address'. If this param is not passed, by default, we will take the display name of your Zoho email account.
replyto_emailStringSpecify the 'Reply to' email address to which you want the receipients response email to be sent.

Note:

  • We have also provided an option to configure the values for all the above parameters while creating the document itself.
  • If you have saved the merge settings earlier by configuring the parameter values, then we will get those values (by default) if you miss to pass the parameters while sending the API request.
  • Optional parameters are not supported in mergeAndSend deluge task. To make use of them, you need to use the invokeURL task with this API.

Curl

Sample Request

Copiedcurl --location --request POST "https://www.zohoapis.com/writer/api/v1/documents/ponazfea04477109f4681a831e7177d96bc40/merge/email" \
  --header "Authorization: Zoho-oauthtoken xxx.yyy.zzz" \
  --form "output_format=inline" \
  --form "subject=Email Subject" \
  --form "recipient_email=amelia@zylker.com" \
  --form "merge_data={\"data\":[{\"name\":\"Amelia\",\"email\":\"amelia@zylker.com\"}, {\"name\":\"John\",\"email\":\"john@zylker.com\"}]}"

Sample Response

Copied{
    "merge_report_data_url": "http://writer.zoho.com/writer/api/v1/merge/job/ponazfea04477109f4681a831e7177d96bc40/data",
    "merge_report_url": "http://writer.zoho.com/writer/v1/mailmerge/job/ponazfea04477109f4681a831e7177d96bc40",
    "records": [
        {
            "data": {
                           "name": "Amelia",
                           "email": "amelia@zylker.com"
                         },
            "download_link": "{url}",
            "status": "inprogress"
        },
        {
            "data": {
                           "name": "John",
                           "email": "john@zylker.com"
                         },
            "download_link": "{url}",
            "status": "inprogress"
        }
    ],
}

// When 'merge_report_data_url' is invoked, you will receive the below response;

{
    "records": [
        {
            "data": {
                           "name": “Amelia”,
                           "email": “amelia@zylker.com"
            },
            "status": "completed"
        },
        {
            "data": {
                           "name": “John”,
                           "email": “john@zylker.com"
            },
            "status": "inprogress"
        }
    ],
    "status": "inprogress"
}
 

Deluge

Snippet 1

Copieddata = Map(); 
data.put("InvoiceNo","12345"); 
data.put("InvoiceDate","27 May 2022"); 
data.put("InvoiceAmount","$100");
param = Map(); 
param.put("message", "Reg Invoice \n Please find your invoice attached."); 
param.put("subject", "Invoice Data"); 
param.put("merge_data", {"data":data}); 
param.put("output_format", "inline"); 
param.put("recipient_email","amelia@zylker.com"); 
param.put("cc_email", "john@zylker.com"); 
param.put("bcc_email", "kim@zylker.com"); 
param.put("from_email", "jackson@zylker.com");  
param.put("password","test"); 
invokeurl 
[ 
url: "https://www.zohoapis.com/writer/api/v1/documents/fbsa6360a78f53f564dfa9b4a1e79febed569/merge/email" 
type: post 
parameters: param 
connection: "<connection_name>" 
];

Sample Response

Copied{
    "merge_report_data_url": "http://writer.zoho.com/writer/api/v1/merge/job/fbsa6360a78f53f564dfa9b4a1e79febed569/data",
    "merge_report_url": "http://writer.zoho.com/writer/v1/mailmerge/job/fbsa6360a78f53f564dfa9b4a1e79febed569",
    "records": [
        {
            "InvoiceNo": "12345",
            "InvoiceDate": "27 May 2022",
            "InvoiceAmount": "$100",
            "download_link": "{url}",
            "status": "inprogress"
        }
    ],
}

Snippet 2 - Merge and Email with common attachments

Copiedmessage = "Hello \n Team";
fields = invokeurl
[
	url :"https://www.zohoapis.com/writer/api/v1/documents/eb4kob4cf6***61119eb9/fields"
	type :GET
	connection:”<connection_name>“
];
data = Map();
data.put("InvoiceNo","12345"); 
data.put("InvoiceDate","27 May 2022"); 
data.put("InvoiceAmount","$100");
dataMap = Map();
dataMap = {"data":data};
commonAttachmentFile1 = invokeurl
[
	url :"https://example.com/download/publicdocument"
	type :GET
];
info commonAttachmentFile1;
commonAttachmentFile2 = invokeurl
[
	url :"https://example.com/download/publicdocument"
	type :GET
];
info commonAttachmentFile2;
commonAttachmentFile2.setParamName("common_attachments");

// If we have more then one common attachment should setParam for them.

paramList = list();
paramMap1 = {"paramName":"common_attachments","content":commonAttachmentFile1}; 
paramMap8 = {"paramName":"common_attachments1","content":commonAttachmentFile2};
paramMap2 = {"paramName":"merge_data","content":dataMap.toString(),"stringPart":"true"};
paramMap3 = {"paramName":"subject","content":"Invoice data","stringPart":"true"}; 
paramMap4 = {"paramName":"message","content":"Reg Invoice \n Please find your invoice attached.,"stringPart":"true"}; 
paramMap5 = {"paramName":"attachment_name","content":"attachment_name","stringPart":"true"};
paramMap6 = {"paramName":"output_format","content":"inline","stringPart":"true"};
paramMap7 = {"paramName":"recipient_email","content":"amelia@gmail.com","stringPart":"true"};
paramList.add(paramMap1);
paramList.add(paramMap2);
paramList.add(paramMap3);
paramList.add(paramMap4);
paramList.add(paramMap5);
paramList.add(paramMap6);
paramList.add(paramMap7);
paramList.add(paramMap8);
merge = invokeurl
[
	url :"https://www.zohoapis.com/writer/api/v1/documents/eb4kob4cf6***61119eb9/merge/email"
	type :POST
	files:paramList
	connection:"<connection_name>"
];
info merge;

Sample Response

Copied{
    "merge_report_data_url": "http://writer.zoho.com/writer/api/v1/merge/job/eb4kob4cf6***61119eb9data",
    "merge_report_url": "http://writer.zoho.com/writer/v1/mailmerge/job/eb4kob4cf6***61119eb9",
    "records": [
        {
             "InvoiceNo": "12345",
            "InvoiceDate": "27 May 2022",
            "InvoiceAmount": "$100",
            "download_link": "{url}",
            "status": "inprogress"
        }
    ],
}

Snippet 3 - Merge and Email Task (Inline)

Copieddata = {"data":{"InvoiceNo":"12345","InvoiceDate":"27 May 2022","InvoiceAmt":"$100"}};
mergedata = Map();
mergedata.put("merge_data", data);
mergedata.put("subject", "Invoice Data");   //optional
zoho.writer.mergeAndSend("fbsa6360a78f53f564dfa9b4a1e79febed569", "inline", "amelia@zylker.com", mergedata, "<connection_name>");

Sample Response

Copied{
    "merge_report_data_url": "http://writer.zoho.com/writer/api/v1/merge/job/fbsa6360a78f53f564dfa9b4a1e79febed569/data",
    "merge_report_url": "http://writer.zoho.com/writer/v1/mailmerge/job/fbsa6360a78f53f564dfa9b4a1e79febed569",
    "records": [
        {
             "InvoiceNo": "12345",
            "InvoiceDate": "27 May 2022",
            "InvoiceAmount": "$100",
            "download_link": "{url}",
            "status": "inprogress"
        }
    ],
}