Send emails with attachments and crm template from Zoho crm
Wed Sep 18 2024 14:46:43 GMT+0000 (Coordinated Universal Time)
Saved by
@usman13
/////
response = invokeurl
[
url :"https://www.zohoapis.com/crm/v5/Leads/" + rec_id + "/Attachments?fields=id,Owner,File_Name,Created_Time,Parent_Id"
type :GET
connection:"zoho_crm2"
];
//info response;
resp_data = response.get("data");
//info resp_data;
for each data in resp_data
{
File_Name = data.get("File_Name");
//info File_Name;
if(File_Name.contains("DRIVER APPLICATION"))
{
file_id1 = data.get("id");
info file_id1;
download_response = invokeurl
[
url :"https://www.zohoapis.com/crm/v5/Leads/" + rec_id + "/Attachments/" + file_id1 + ""
type :GET
connection:"zoho_crm2"
];
info download_response;
download_response.setParamName("file");
upload_response = invokeurl
[
url :"https://www.zohoapis.com/crm/v6/files"
type :POST
files:download_response
connection:"zoho_crm2"
];
//info upload_response;
resp_data = upload_response.get("data");
for each rec in resp_data
{
file_id = rec.get("details").get("id");
//info file_id;
}
}
}
finallist = List();
frommp = Map();
frommp.put("email",from_email);
// frommp.put("email","zach.dugger@claimshieldpro.com");
mp = Map();
mp.put("from",frommp);
tomaplist = List();
tomap = Map();
tomap.put("email",manager_email_id);
tomaplist.add(tomap);
//…….Multiple Receiver………
tomap1 = Map();
tomap1.put("email",manager_email_id);
tomaplist.add(tomap1);
mp.put("to",tomaplist);
//..........Get Template Data............
TemplateID = "2314579000150955209";
templatemap = Map();
templatemap.put("id",TemplateID);
mp.put("template",templatemap);
mp.put("org_email",True);
//////
///////
attachmentlist = List();
attachmentmap = Map();
attachmentmap.put("id",file_id);
attachmentlist.add(attachmentmap);
mp.put("attachments",attachmentlist);
///////
finallist.add(mp);
finalmap = Map();
finalmap.put("data",finallist);
//info finallist;
///////
send_mail_resp = invokeurl
[
url :"https://www.zohoapis.com/crm/v5/Leads/" + rec_id + "/actions/send_mail"
type :POST
parameters:finalmap.toString()
connection:"zoho_crm2"
];
info send_mail_resp;
content_copyCOPY
Comments