Mails are not being sent from custom Deluge function
We are having troubles to implement sending Invoices / Sales_Orders etc. automatically using following deluge script:
- attachment_template_id = "aaaa";
- record_id = "bbbb";
- mail_template_id = "cccc";
- //NEW aproach
- fileUrl = "https://www.zohoapis.com/crm/v8/settings/inventory_templates/" + attachment_template_id + "/actions/print_preview?record_id=" + record_id + "&print_type=pdf";
- download = invokeurl
- [
- url :fileUrl
- type :GET
- connection:"zzz"
- ];
- info download;
- download.setParamName("file");
- info download;
- //info downloadFile;
- response = invokeurl
- [
- url :"https://www.zohoapis.com/crm/v8/files"
- type :POST
- files:download
- connection:"zzz"
- ];
- info "zfs : " + response;
- fid = response.get("data").get(0).get("details").get("id");
- info fid;
- sendfrom = Map();
- sendfrom.put("email",zoho.adminuserid);
- sendto = Map();
- sendto.put("email","XXXXX");
- tolist = List();
- tolist.add(sendto);
- attmp = Map();
- attmp.put("id",fid);
- alist = List();
- alist.add(attmp);
- tempmp = Map();
- tempmp.put("id", mail_template_id);
- mp = Map();
- mp.put("from",sendfrom);
- mp.put("to",tolist);
- mp.put("attachments",alist);
- mp.put("template",tempmp);
- intm = Map();
- intm.put("inventory_template", {"id":attachment_template_id, "name": "SalesOrder.pdf"});
- mp.put("inventory_details", intm);
- mp.put("template",tempmp);
- dlist = List();
- dlist.add(mp);
- data = Map();
- data.put("data",dlist);
- info data;
- // info mp;
- sendmail = invokeurl
- [
- url :"https://www.zohoapis.com/crm/v2.1/Invoices/" + record_id + "/actions/send_mail"
- type : POST
- parameters:data + ""
- connection:"zzz"
- ];
- info sendmail;
We get the following return (from info sendmail):
- {"data":[{"code":"SUCCESS","details":{"message_id":"XXXXX"},"message":"Your mail has been sent successfully.","status":"success"}]}
But the mail does not get delivered.
We also tried to use API version 8, no difference.
We tried using deluge sendmail function before, which worked, but the mail does not appear in the "sent" folder.