Sc_mail_send send to variable field

Hi There

Please can someone help me out with a bit of code.

I have a pdf report made from a form for jobcards which calls info from customers table, vehicles table and services table and then calculates totals and then saved as a record in my jobcard table.

At the top of the toolbar i have a “invoice pdf” button which just generates a pdf report from the jobcard form and opens to a browser window.

I copied the pdfreport and renamed it with a sub_email and inserted the sc_pdf_output macro which creates a pdf of the inovice to my local server, and then on scriptinit i run the sc_mail_send with attachment.

which works perfectly and sends the pdf invoice to the email address stipulated in the the sc_mail_send, $mail_to field.

However, i want to send the pdf to email stipulated in the customer email field for the relevant job.

The report form is setup to request the jobcard id to be enetered as it is linked to the jobcard form. I’m just not sure how to retrieve the customer email field and send it to, when hitting the “email PDF invoice” button to the customer.

Just bumping, I’m sure I have to define the customer email variable, at the moment the field name in the report is {customeremail}