Mails are not being sent from custom Deluge function

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:

  1. attachment_template_id = "aaaa";
  2. record_id = "bbbb";
  3. mail_template_id = "cccc";
  4. //NEW aproach
  5. fileUrl = "https://www.zohoapis.com/crm/v8/settings/inventory_templates/" + attachment_template_id + "/actions/print_preview?record_id=" + record_id + "&print_type=pdf";
  6. download = invokeurl
  7. [
  8. url :fileUrl
  9. type :GET
  10. connection:"zzz"
  11. ];
  12. info download;
  13. download.setParamName("file");
  14. info download;
  15. //info downloadFile;
  16. response = invokeurl
  17. [
  18. url :"https://www.zohoapis.com/crm/v8/files"
  19. type :POST
  20. files:download
  21. connection:"zzz"
  22. ];
  23. info "zfs : " + response;

  24. fid = response.get("data").get(0).get("details").get("id");
  25. info fid;

  26. sendfrom = Map();
  27. sendfrom.put("email",zoho.adminuserid);
  28. sendto = Map();
  29. sendto.put("email","XXXXX");
  30. tolist = List();
  31. tolist.add(sendto);
  32. attmp = Map();
  33. attmp.put("id",fid);
  34. alist = List();
  35. alist.add(attmp);
  36. tempmp = Map();
  37. tempmp.put("id", mail_template_id);
  38. mp = Map();
  39. mp.put("from",sendfrom);
  40. mp.put("to",tolist);
  41. mp.put("attachments",alist);
  42. mp.put("template",tempmp);
  43. intm = Map();
  44. intm.put("inventory_template", {"id":attachment_template_id, "name": "SalesOrder.pdf"});
  45. mp.put("inventory_details", intm);
  46. mp.put("template",tempmp);
  47. dlist = List();
  48. dlist.add(mp);
  49. data = Map();
  50. data.put("data",dlist);
  51. info data;
  52. // info mp;
  53. sendmail = invokeurl
  54. [
  55. url :"https://www.zohoapis.com/crm/v2.1/Invoices/" + record_id + "/actions/send_mail"
  56. type : POST
  57. parameters:data + ""
  58. connection:"zzz"
  59. ];
  60. info sendmail;
We get the following return (from info sendmail):

  1. {"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.