Send Email using spfx (no framwork)
private sendEmail(): void {
const siteUrl = this.context.pageContext.web.absoluteUrl;
const emailUrl = siteUrl + '/_api/SP.Utilities.Utility.SendEmail';
const reqOptions: ISPHttpClientOptions = {
headers: {
"Accept": "application/json;odata=verbose",
"Content-Type": "application/json;odata=verbose",
"odata-version":"3.0",
},
body: JSON.stringify({
'properties': {
'__metadata': { 'type': 'SP.Utilities.EmailProperties' },
'To': { 'results': ['sentk@deloitte.com'] },
'Body': 'Ignore this test email.',
'Subject': 'Invoice Uploader Test Email'
}
})
};
this.context.spHttpClient.post(emailUrl, SPHttpClient.configurations.v1, reqOptions)
.then((response: SPHttpClientResponse) => {
console.log(`Status code: ${response.status}`);
console.log(`Status text: ${response.statusText}`);
response.json().then((responseJSON: JSON) => {
console.log(responseJSON);
});
})
.catch((err) => {
console.log(err);
});
}
Comments
Post a Comment