Pull data from form and create email

  • Pull data from form and create email

    Posted by Isaac Harned on July 27, 2023 at 1:58 pm

    Have a script I am trying to write that will execute on button push.

    I have everything working that I need to except for one thing, the hyperlink.

    Anyone know how to use the “const link” function?

    var eabJobNumber = this.getField(“EAB Job Number”).value;

    var currentDocument = this.path;

    var cMyMsg = currentDocument; //this is what I need to convert before pasting into the body

    app.mailMsg({

    bUI: true,

    cTo: “address”,

    cSubject: eabJobNumber + ” Job Transmittal”,

    cMsg: cMyMsg

    });

    Isaac Harned replied 9 months, 1 week ago 2 Members · 5 Replies
  • 5 Replies
  • Isaac Harned

    Member
    July 27, 2023 at 2:14 pm
    Points: 6,273
    Rank: UC2 Brainery Purple Belt I UC2 Brainery Purple Belt I

    I see now that it is not possible with the mailMsg method as this by default opens a plain text email and cannot be used to create an HTML email. Any ideas for work arounds?

    • Isaac Harned

      Member
      July 27, 2023 at 2:51 pm
      Points: 6,273
      Rank: UC2 Brainery Purple Belt I UC2 Brainery Purple Belt I

      Ok, a little farther, MIMEType should make this HTML, but it still creates a plain text email. no errors encountered, and all setting in Outlook set to create in HTML.

      var eabJobNumber = this.getField(“EAB Job Number”).value;

      var currentDocument = this.path;

      var cMyMsg = “Click here to view the document”;

      // Compose the email subject and body

      var subject = eabJobNumber + ” Job Transmittal”;

      var body = cMyMsg;

      // Call the mailMsg method with MIMEType set to “text/html” for HTML email

      app.mailMsg({

      bUI: true,

      cTo: “address“,

      cSubject: subject,

      cMsg: body,

      MIMEType: “text/html”

      });

  • Isaac Harned

    Member
    July 27, 2023 at 3:34 pm
    Points: 6,273
    Rank: UC2 Brainery Purple Belt I UC2 Brainery Purple Belt I

    var cMyMsg = “[<a href]='” + currentDocument + “‘>Click here to view the document”;


    (it automatically converted the link when I posted)

  • Michael

    Member
    July 27, 2023 at 4:54 pm
    Points: 509
    Rank: UC2 Brainery White Belt UC2 Brainery White Belt Rank

    // Assuming you have the URL that you want to hyperlink to

    const linkURL = “https://example.com”;

    // Modify the cMyMsg variable to include the hyperlink HTML

    var cMyMsg = “

    This is the email body content.

    “;

    cMyMsg += “

    Click here to visit the link.

    “;

    // Rest of your code

    var eabJobNumber = this.getField(“EAB Job Number”).value;

    var currentDocument = this.path;

    app.mailMsg({

    bUI: true,

    cTo: “address”,

    cSubject: eabJobNumber + ” Job Transmittal”,

    cMsg: cMyMsg

    });

    • Isaac Harned

      Member
      July 27, 2023 at 9:23 pm
      Points: 6,273
      Rank: UC2 Brainery Purple Belt I UC2 Brainery Purple Belt I

      This may work, but only if I can get the default email template to be HTML. Unfortunately mailMsg will only open plain text through outlook so far, but I will have to do some testing in other apps.

Log in to reply.