Attachment
Purpose
To send the merge document as attachment with a message in the body of the email.
HTTP Request URL
https://{zohoapis_domain}/writer/api/v1/documents/{{document_id}}/merge/email
Path Parameters
Parameter | Data Type | Description |
Mandatory Parameters | ||
document_id | String | Specify a unique id for the writer document. |
Body Parameters
Parameter | Data Type | Description |
Mandatory Parameters | ||
output_format | String | Specify the format in which the merged document needs to attached and sent. Supported formats are pdf, pdfform and docx. |
subject | String | Specify a subject to the email. |
message | String | Specify a message related to the attachment in the email. |
recipient_email | String | Specify the receiver's email id. |
You can provide the data in any one of the below formats | ||
merge_data | JSONObject | Pass a String value through 'data' key as JSON Array. |
merge_data_csv_content | File | Provide the required csv content in your API request body. |
merge_data_json_content | File | Provide the required json content in your API request body. |
merge_data_csv_url | url | Provide the required csv url in your API request body. |
merge_data_json_url | url | Provide the required json url in your API request body. |
record_id | String | Instead of using merge_data, you can pass the record_id and we will fetch the data internally. Note: This is applicable only for Zoho CRM, Creator, Recruit and Bigin templates. Maximum length allowed: 25 |
Optional Parameters | ||
cc_email | String | Specify the Cc email id's (maximum upto 10) separated by comma. |
bcc_email | String | Specify the BCC email id's (maximum upto 10) separated by comma. |
password | String | Specify a password if you would like to protect the merged document. |
attachment_name | String | Specify a name (without extension) for the merged document (pdf or docx) that is attached in the mail.
For example: "attachment_name = test" (extension will be automatically added according to the attached file format) |
from_email | String | 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_attachments | File | 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 | { (OR) { | 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_name | String | Specify 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_email | String | Specify the 'Reply to' email address to which you want the receipients response email to be sent. |
sign_service_name | String | This param needs to be configured when you would like to upload the merged document with signer fields to a third party sign service.
Possible values: adobesign and docusign
Note: This param can be used only when the 'output_format' param value is configured as pdf. |
test_mode | Boolean (true/false) | Using this param, you can test the Merge APIs without consuming any credit points. The output file will contain a watermark as it is used only for testing purpose.
Test mode limit: 50 merges/day for an org. |
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.
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=pdf" \
--form "message=Email Message" \
--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": "https://writer.zoho.com/writer/api/v1/merge/job/0tq5n465132106580437abe99b6f56f2b0c85/data",
"merge_report_url": "https://writer.zoho.com/writer/v1/mailmerge/job/0tq5n465132106580437abe99b6f56f2b0c85",
"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"
}
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", "pdf");
param.put("recipient_email","amelia@zylker.com");
param.put("cc_email", "john@zylker.com"); //optional
param.put("bcc_email", "kim@zylker.com"); //optional
param.put("from_email", "jackson@zylker.com"); //optional
param.put("password","*****"); //optional
param.put("attachment_name", "Invoice"); //optional
param.put("from_name", "Jack"); //optional
param.put("replyto_email", "jerry@zylker.com"); //optional
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": "https://writer.zoho.com/writer/api/v1/merge/job/fbsa6360a78f53f564dfa9b4a1e79febed569/data",
"merge_report_url": "https://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};
downloadFile = invokeurl
[
url :"https://homepages.inf.ed.ac.uk/neilb/TestWordDoc.doc"
type :GET
];
info downloadFile;
commonAttachmentFile1 = invokeurl
[
url :"https://example.com/download/publicdocument"
type :GET
];
info commonAttachmentFile1;
commonAttachmentFile2 = invokeurl
[
url :"https://example.com/download/publicdocument"
type :GET
];
info commonAttachmentFile2;
downloadFile.setParamName("common_attachments");
commonAttachmentFile2.setParamName("common_attachments");
paramList = list();
paramMap1 = {"paramName":"common_attachments","content":commonAttachmentFile1};
paramMap8 = {"paramName":"common_attachments1","content":commonAttachmentFile2};
paramMap2 = {"paramName":"merge_data","content":dataMap.toString(),"stringPart":"true","encodingType":"UTF-8"};
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":"pdf","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": "https://writer.zoho.com/writer/api/v1/merge/job/fbsa6360a78f53f564dfa9b4a1e79febed569/data",
"merge_report_url": "https://writer.zoho.com/writer/v1/mailmerge/job/fbsa6360a78f53f564dfa9b4a1e79febed569",
"records": [
{
"InvoiceNo": "12345",
"InvoiceDate": "27 May 2022",
"InvoiceAmount": "$100",
"download_link": "{url}",
"status": "inprogress"
}
],
}
Snippet 3 - Merge and Email Task (Attachment Type)
Copieddata = {"data":{"InvoiceNo":"12345","InvoiceDate":"27 May 2022","InvoiceAmt":"$100"}};
mergedata = Map();
mergedata.put("merge_data", data);
mergedata.put("subject", "Invoice data");
mergedata.put("message", "Please find your invoice in the attachment");
zoho.writer.mergeAndSend("fbsa6360a78f53f564dfa9b4a1e79febed569", "docx", "amelia@zylker.com", mergedata, "<connection_name>"); //outputformat -> pdf/docx
Sample Response
Copied{
"merge_report_data_url": "https://writer.zoho.com/writer/api/v1/merge/job/fbsa6360a78f53f564dfa9b4a1e79febed569/data",
"merge_report_url": "https://writer.zoho.com/writer/v1/mailmerge/job/fbsa6360a78f53f564dfa9b4a1e79febed569",
"records": [
{
"InvoiceNo": "12345",
"InvoiceDate": "27 May 2022",
"InvoiceAmount": "$100",
"download_link": "{url}",
"status": "inprogress"
}
],
}