Populate Email Address and Relate To field in Email

I have a custom module that I created.
I added the custom code:

 "customCode' => '<input type="button" class="button" onClick="showPopup(\'emailpdf\');" value="{$MOD.LBL_EMAIL_PDF}">',

The compose Email window pops up and my email attachment is there but I have no clue how to populate the following fields: Relate to, the email template, and most importantly, the to address.

How do you populate these?

Here is some Compose Email button code I just grabbed from a screen:

<a class="email-link" href="mailto:info99@example.it" onclick="currentModule='Leads';$(document).openComposeViewModal(this);" 
  data-module="Leads"  
  data-record-id="19ce39bd-6fd6-7ffc-d5c8-5b62265807b5" 
  data-module-name="Krystal Tipler" 
  data-email-address="info99@example.it">info99@example.it</a>

Which loads this pop-up:

image

If you search the code for those argument names you might find out more. I don’t know how to set the email template, if you can find a place in the SuiteCRM UI where that happens, investigate that with the browser developer tools…

I like this solution but the issue is that this code does not attach the PDF.

You’re right. I tried looking at the code, but I don’t understand how that popup(‘emailpdf’) produces an email compose window. I can see it generating the PDF, but I don’t see anything taking it to a Compose window, I must be missing something…