1

Just wondering if I could get some help. I built a small webpart that sends an email. On my local workbench it works fine however when I deploy to production

Error: Error making HttpClient request in queryable [404] Not Found ::>

My Import

import { sp,  EmailProperties } from "@pnp/sp";

My OnInit establishes context

 public onInit(): Promise<void> {
    return super.onInit().then(_ => {
      // establish SPFx context
      sp.setup({
        spfxContext: this.context
      });

    });
  }

Send email

  const emailProps: EmailProperties = {
          To: ["[email protected]"],
          Subject: "This email is about...",
          Body: "Here is the body. <b>It supports html</b>"
        };

        sp.utility.sendEmail(emailProps).then(_ => {
          console.log("Email Sent!");
        });

1 Answer 1

3

Sorry, stupidity on my part.

Correct code is:

sp.setup({
    spfxContext: this.props.context
});
1
  • Hi Lori, I have the same issue. But when I add this.props.context. It comes up with an error Property props does not exist on type "MyWebPart". Can you share you code Commented Jul 8, 2019 at 16:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.