Send Email Template Using Deluge in Zoho CRM

[Zoho CRM] Send Email Template Using Deluge in Zoho CRM

How to send an email using an email template in a Deluge/Custom Function/Button?

This function is used to send email using Zoho CRM email templates. We would have to get the template id by going to the respective template and edit it. In the URL of the edit page, there is a long string of numbers. That is the template id. Please note that this function intends to send an email to the contacts module, but it is created in the deal module. Use case? for example, when a Deal is closed, we want to send an email to the contact. We can use it in workflow, blueprint, or even modify it slightly to be a button.

Also, "zcrm" is the connection name I am using. You can replace it with your own connection name that has the right permissions within Zoho CRM. 

  1. //define template id here. replace it with your own
  2. templateId = "2700842021110819999";
  3. //get the contact id from the deal record
  4. contactId = ifnull(zoho.crm.getRecordById("Deals",dealId).get("Contact_Name").get("id"),"");
  5. //get the email from the contact record
  6. contactEmail = ifnull(zoho.crm.getRecordById("Contacts",contactId).get("Email"),"");
  7. //send mail if email is not null
  8. if(contactEmail != "")
  9. {
  10. data = List();
  11. datainformation = Map();
  12. datainformation.put("from",{"email":"youremailhere@domain.com,"username":"your username here"});
  13. datainformation.put("to",{{"email":contactEmail}});
  14. datainformation.put("org_email",true);
  15. datainformation.put("template",{"id":templateId});
  16. data.add(datainformation);
  17. mapdata = Map();
  18. mapdata.put("data",data);
  19. sendSurvey = invokeurl
  20. [
  21. url :"https://www.zohoapis.com/crm/v5/Contacts/" + contactId.toString() + "/actions/send_mail"
  22. type :POST
  23. parameters:mapdata.toString()
  24. connection:"zcrm"
  25. ];
  26. info sendSurvey;
  27. }

Good luck!