Preview:
response = invokeurl
[
	url :"https://www.zohoapis.com/crm/v5/POP_Requests/" + pop_id + "/Attachments?fields=id,Owner,File_Name,Created_Time,Parent_Id"
	type :GET
	connection:"newzohocrm"
];

// Get attachment list
attachments_data = response.get("data");
file_id = "";

for each data in attachments_data
{
	file_id1 = data.get("id");

	// Download attachment
	download_response = invokeurl
	[
		url :"https://www.zohoapis.com/crm/v5/POP_Requests/" + pop_id + "/Attachments/" + file_id1
		type :GET
		connection:"newzohocrm"
	];
	download_response.setParamName("file");

	// Upload to Files
	upload_response = invokeurl
	[
		url :"https://www.zohoapis.com/crm/v6/files"
		type :POST
		files:download_response
		connection:"newzohocrm"
	];

	upload_data = upload_response.get("data");
	for each rec in upload_data
	{
		file_id = rec.get("details").get("id");
		info file_id;
	}
}

// Email parameters
from_email = "crm@leosuk.com";
manager_email_id = "muhammad.usman@leosops.com";

finallist = List();
frommp = Map();
frommp.put("email", from_email);
frommp.put("user_name", "LEOS Developments LLC");

mp = Map();
mp.put("from", frommp);

// To List (FIXED)
tomaplist = List();
tomap = Map();
tomap.put("email", manager_email_id);
tomap.put("user_name", "Usman");
tomaplist.add(tomap);
mp.put("to", tomaplist); // ✅ fixed

// Email Template
TemplateID = "5971686000095227019";
templatemap = Map();
templatemap.put("id", TemplateID);
mp.put("template", templatemap);
mp.put("org_email", true);

// Attachments
attachmentlist = List();
attachmentmap = Map();
attachmentmap.put("id", file_id);
attachmentlist.add(attachmentmap);
mp.put("attachments", attachmentlist);

// Final payload
finallist.add(mp);
finalmap = Map();
finalmap.put("data", finallist);
info finalmap;

// Send Email
send_mail_resp = invokeurl
[
	url :"https://www.zohoapis.com/crm/v5/POP_Requests/" + pop_id + "/actions/send_mail"
	type :POST
	parameters: finalmap.toString()
	connection:"newzohocrm"
];

info send_mail_resp;
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter