0

Add userEmail() or field to dialog

This is my script to send an email, how do I add the userEmail() or field to it to show the sender email or field content please?

let title := "Send Email";
let message := "Do you need to add a CC?
If you do click 'Yes, I do' and add it.";
let answerOptions := ["Yes, I do", "No, I don't"];
if dialog(title, message, answerOptions) = "No, I don't" then
    sendEmail({
        from: "alan@xxxxxxxxx.com",
        to: 'EMAIL TO',
        cc: CC,
        subject: 'WORK REPORT OF',
        text: "REPORT" + "
" + "
" + REPORT
    });
    alert("Email Sent!")
end

5 replies

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

    Not sure if I understand your question...

    Do you want to know who the user is with the userEmail() function and display his email in a formula field? Do you want it to popup in your dialog? Do you want to use his email to send the actual email?

    I believe your code also doesn't work if the answer in "Yes, i do". May I suggest following code?

    let sender := userEmail();
    let CR := urlDecode("%0D%0A");
    let ccReceiver := "";
    let responce := dialog("Send Email","Do you need to add a CC?"+CR+"If you do click 'Yes, I do' and add it.",["Yes, I do", "No, I don't"]);
    if responce = "Yes, I do" then
        ccReceiver := CC
    end;
     sendEmail({
            from: sender,
            to: 'EMAIL TO',
            cc: ccReceiver,
            subject: 'WORK REPORT OF',
            text: "REPORT" + "
    " + "
    " + REPORT
        });
        alert(sender + "> sent an email to: " + CR + 'EMAIL TO' + CR + ccSender)

    You may also check this tread for an example of sending emails.

    Steven

      • Alan_Cooke
      • 1 yr ago
      • Reported - view

      RoSoft_Steven Yes I do simply cancels the send so you can add an email to the CC.

      "Do you want it to popup in your dialog?"  Exactly.

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

      Alan Cooke 

      I extended the code to check if the field CC is empty or not. If Empty the code stops to fill the CC field.

      function sendmail(send : text,ccReceiv : text,receiv : text,subj : text,repo : text) do
          sendEmail({
              from: send,
              to: receiv,
              cc: ccReceiv,
              subject: subj,
              text: "REPORT" + "
      " + "
      " + repo
          })
      end;
      let sender := userEmail();
      let subject := 'WORK REPORT OF';
      let report := REPORT;
      let receiver := text('EMAIL TO');
      let CR := urlDecode("%0D%0A");
      let ccReceiver := "";
      let responce := dialog("Send Email", "Do you need to add a CC?" + CR + "If you do click 'Yes, I do add it.", ["Yes, I do", "No, I don't"]);
      if responce = "Yes, I do" then
          if CC then
              ccReceiver := CC;
              sendmail(sender, ccReceiver, receiver, subject, report);
              alert(sender + "> sent an email to: " + CR + Ontvanger + CR + ccReceiver)
          else
              alert("Code stopped to fill CC field")
          end
      else
          sendmail(sender, ccReceiver, receiver, subject, report);
          alert(sender + "> sent an email to: " + CR + 'EMAIL TO' + CR + ccReceiver)
      end
      

      Steven

      • Alan_Cooke
      • 1 yr ago
      • Reported - view

      RoSoft_Steven Wow!  Thank you so much - especially die Ontvanger - baie mooi :-)

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

      Alan Cooke oops, forgot to translate 🙈

      should have been 'EMAIL TO' instead ☺️

Content aside

  • 1 yr agoLast active
  • 5Replies
  • 110Views
  • 2 Following