How do I reference and send a HTML Email from Angular.js upon a button click in my app?

Viewed 41

I am a Power Platform developer but have not had any exposure to JavaScript or HTML before and I really need a push in the right direction with a problem that I have been presented with.

What am I trying to achieve?

Essentially within a Sharepoint app once a user clicks a button I want my JavaScript code to trigger the HTML code. I have done a few courses so I could be wrong but I think the script is referencing the HTML script here (I have only provided a small piece of the JS).

AngularJS script
//When check is Rejected by Team by button click in Sharepoint app

$scope.returnMember = function () {
  //$scope.isLoading = true;

  getListData("Members", "Person/EMail", "", "Person").then(function (emails) {
    for (var i in emails) {
      sendTo.push(emails[i].Person.EMail);
    }

    //references the html bellow
    $templateRequest(
      "../../Style Library/Portal/Content/Emails/rejected.html"
    ).then(function (template) {
      var body = {
        ReqID: ($scope.requestDetails.RSF ? "R" : "N") + "SF" + $scope.Id,
        User: ["example@example.com"],
        //Rejection: result,
        //Rejector: $scope.submission.RquestorsName.Title
      };

      Team.sendEmail(
        $interpolate(template)(body),
        "Request " +
          ($scope.requestDetails.RSF ? "R" : "N") +
          "SF" +
          $scope.Id +
          " Rejected",
        [$scope.requestDetails.RquestorsName.EMail]
      );
    });
  });
};
rejected.html
<!-- CONTENT TABLE // -->
<table border="0" cellpadding="0" cellspacing="0" width="96%">
  <tr>
    <td valign="top" class="textContent">
      <div
        style="
          text-align: left;
          font-family: Helvetica, Arial, sans-serif;
          font-size: 15px;
          margin-bottom: 0;
          margin-top: 3px;
          color: #5f5f5f;
          line-height: 135%;
        "
      >
        <p>The request {{ReqID}} has been rejected by {{User}}.</p>
        <p>Reason:</p>
        <p>{{Rejection}}</p>
        <p>
          If you are picking up this request, please click
          <a href="{{link}}">here</a> and allocate this to your name within the
          inbox.
        </p>
      </div>
    </td>
  </tr>
</table>
<!-- // CONTENT TABLE -->

What have I tried?

I have tried to comment out the variable body within the template function in the JavaScript but this only broke my app. I am a little confused as I copied this code from another point in the app where it works fine. I would be greatly appreciative if anyone could shed some light on this situation or point me in the right direction of how I could achieve this. i.e. triggering a HTML email to be sent from within an AngularJS script upon the press of a button in a Sharepoint app.

0 Answers
Related