0

Creating a Record from a Button Sending an Email

Hi,

I've set up buttons to send emails, but I need to keep a record of the emails sent. How can I get this same button to create a record in a new table for storing these emails?

3 replies

null
    • Ninox partner
    • RoSoft_Steven.1
    • 1 yr ago
    • Reported - view

    if you use variables in your sendEmail() function, you can reuse them to create a record. e.g.

    let sender:= userEmail();

    let receiver := ClientEmail;

    let subj := Subject;

    let txt := Textfield;

    let body := raw(RTF-Field);

    sendEmail({ 

    from: sender, 

    to: receiver, 

    subject: subj, 

    text: txt

    html: body, 

    });

    let i := create Emailbackuptable;

    i.(DateandTimefield := now();

       Subject := subj;

       Text := txt;

       SendBy := sender;

       Receiver := receiver;

       message := body)

    You can add more fields if you need to but you get the idea....

    This thread is an example....(and even more than you need)

      • Kate
      • 1 yr ago
      • Reported - view

      RoSoft_Steven Thanks for this, Steven.

      I've now got it creating a record with a time stamp, but I'm not using Recipient/Subject/Body fields to compose the email - it's a generic notification in a coded button that adds in other fields to the coded message body - so I'm not sure how to include the 'body' of the email into the backup record. I've tried just replicating the code for the email content, but that hasn't worked.

      • Kate
      • 1 yr ago
      • Reported - view

      RoSoft_Steven 

      I'm getting a record created with the correct timestamp, but I'm getting "[object Object]" in the Message field - this is the field where I want the email 'body' to appear. 

      This is the code that I'm using:

       

      let result := dialog("Title", "Are you sure you want to send this?", ["Yes", "No"]);

      if result = "Yes" then

      sendEmail({

      from: "User@mail.com",

      to: "admin@mail.com",

      bcc: "user@mail.com",

      subject: "Certificates Uploaded to Ninox",

      text: "Hello,

       

      The certificates for " +

      'f-Name of Course' +

      " on the  " +

      Appointment +

      " at " +

      'Address of Venue' +

      " for " +

      CLIENTS.Client +

      " have now been uploaded to Ninox.

       

      " +

      'Certificate Notes' +

      "

       

      With thanks"

      });

      let b := ({

      text: "from: User,

      to: admin,

      bcc: User,

      subject: Certificates Uploaded to Ninox,

      text: Hello,

       

      The certificates for" +

      'f-Name of Course' +

      " on the  " +

      Appointment +

      " at " +

      'Address of Venue' +

      " for " +

      CLIENTS.Client +

      " have now been uploaded to Ninox.

       

      " +

      'Certificate Notes' +

      "

       

      With thanks"

      })

      let i := (create Emails);

      i.(Sent := now();

      Message := b

      );

      end

Content aside

  • 1 yr agoLast active
  • 3Replies
  • 160Views
  • 2 Following