Skip to content
This repository was archived by the owner on Aug 28, 2024. It is now read-only.

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.

sendEmail

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).

EmailProperties

export interface EmailProperties {

    To: string[];
    CC?: string[];
    BCC?: string[];
    Subject: string;
    Body: string;
    AdditionalHeaders?: TypedHash<string>;
    From?: string;
}

Usage

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!");
});

getCurrentUserEmailAddresses

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";

Clone this wiki locally