This repository was archived by the owner on Aug 28, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 227
Working With: SP.Utilities.Utility
Patrick Rodgers edited this page May 1, 2017
·
3 revisions
Added in 2.0.5
Through the REST api you are able to call a subset of the SP.Utilities.Utility methods. We have explicitly defined some of these methods and provided a method to call any others in a generic manner. These methods are exposed on pnp.sp.utility and support batching and caching.
This methods allows you to send an email based on the supplied arguments. The method takes a single argument, a plain object defined by the EmailProperties interface (shown below).
export interface EmailProperties {
To: string[];
CC?: string[];
BCC?: string[];
Subject: string;
Body: string;
AdditionalHeaders?: TypedHash<string>;
From?: string;
}You must define the To, Subject, and Body values - the remaining are optional.
import pnp, { EmailProperties } from "sp-pnp-js";
const emailProps: EmailProperties = {
To: ["[email protected]"],
CC: ["[email protected]", "[email protected]"],
Subject: "This email is about...",
Body: "Here is the body. <b>It supports html</b>",
};
pnp.sp.utility.sendEmail(emailProps).then(_ => {
console.log("Email Sent!");
});This method returns the current user's valid list of email addresses known to SharePoint. Typically this will be an array with zero or one item.
import pnp from "sp-pnp-js";
Sharing is caring!