I'm looking to create a function that mail merges a PDF document, and sends it via email. The email is sent from an organization email address, and it has to be attached to the "emails" section of the record that triggers the function.
Originally, I used the task zoho.writer.mergeAndSend, but I wasn't able to customize the sender, nor attach the email to the CRM record.
I also used the "send mail" deluge task. The function worked ok, merging the PDF and sending the email, but I wasn't able to attach the email to the CRM record.
The last function I tested was using the
send_mail task of the CRM API 3.0. This function allows me to select the company email as the sender, send the email using a template, and attach the email to the CRM record. The problem is, I'm not able to attach the PDF generated in a previous step using the task zoho.writer.mergeAndDownload. Below is the second part of the function.
How can I attach the PDF to the email?
from_name = "Testing Name";
from_email = "testing@mytestingemail.com";
module_name = "Deals";
org_email_address = true;
to_email = {{"email":"test@test.com"}};
//template_data = {"id":4434180000064050000};
template_data = {"id":4434180000064050000,"attachments:file":create_and_download};
email_subject = "Email Subject";
email_payload = {"data":{{"from":{"user_name":from_name,"email":from_email},"to":to_email,"org_email":org_email_address,"subject":email_subject,"mail_format":"html","template":template_data}}};
info email_payload;
send_mail_resp = invokeurl
[
type :POST
parameters:email_payload.toString()
connection:"emailtemplate"
];