0

How do you code a button to send an email with an attachment?

I'm trying to create a button to email a receipt, the code i've tried is:

let myname := Customers.'Full Name' + "Receipt.pdf";
importFile(this, printAndSaveRecord(this, "Receipt"), myname);
let GTCReceipt := file(this, myname);
sendEmail({
from: userEmail(user()),
to: text(Email_for_Quote),
cc: "email address of business owner",
subject: "GTC Receipt",
text: "Hi, " + Customers.Forename + "

Thanks for your payment, your receipt is attached.

Many thanks. ' 

attachments: GTCReceipt
});
alert("Receipt eMailed")

 

The file saves ok, and the alert is created okay, but no emails are sent to either the to: or cc: 

what am i doing wrong. I use ipad, Mac desktop and ninox cloud through safari

1 reply

null
    • Martin_Gillespie_Tree
    • 4 yrs ago
    • Reported - view

    I've got this working now. The to: & cc: entries had to be

    to: text(Email_for_Invoice)

    and

    cc: text(email address of business owner).  

     

    The field Email_for_Quote had trigger processing associated with it to trigger the same address to the Email_for_Invoice field.

    The Email_for_Invoice had no additional processing.

    The reason for the two fields was I wanted to see the email address on two different tabs on the view form, also there are a few rare occassions when we quote to one person and invoice another.

Content aside

  • 4 yrs agoLast active
  • 1Replies
  • 1750Views