pnp / pnpjs

Fluent JavaScript API for SharePoint and Microsoft Graph REST APIs
https://pnp.github.io/pnpjs/
Other
742 stars 302 forks source link

Email Notification delays while send email using @pnp/sp/utilities #3029

Closed bhoomesh-spe closed 2 months ago

bhoomesh-spe commented 2 months ago

What version of PnPjs library you are using

3.x

Minor Version Number

3.15.0

Target environment

SharePoint Framework

Additional environment details

SharePoint Online, SPFx React

Question/Request

Hello Everyone,

I need to send email notifications while adding/updating the SharePoint list items. So, I have used @pnp/sp/utilities for the same.

I have implemented the below call to send an email notification while adding/updating the SharePoint list items.

import { spfi } from "@pnp/sp";
import "@pnp/sp/sputilities";
import { IEmailProperties } from "@pnp/sp/sputilities";

export const sendMail = async (mailProperties) => {
    const sp: SPFI = getSP();
    const emailProps: IEmailProperties = mailProperties;
    await sp.utility.sendEmail(emailProps);
};

The email notifications functionality is working as expected but sometimes we face delays in the email notifications.

Can anyone help me with the same?

Thanks

patrick-rodgers commented 2 months ago

We don't send the emails, we just send the request to the server. It may be that the service is busy or something else happens that queues the emails for later delivery.

bhoomesh-spe commented 2 months ago

@patrick-rodgers Thanks for the quick response. Is there any alternative to sending an email with a client-side code like @pnp/sp/utilities?

juliemturner commented 2 months ago

@bhoomesh-spe - Yes, I've switched to using the graph sendMail endpoint with a "service" type user... that is to say a licensed user for at least Exchange.

bhoomesh-spe commented 2 months ago

@juliemturner - I need to create an app in the Azure portal to make calls with graph api. Is it correct?

juliemturner commented 2 months ago

yes/no... No, you don't need to create a separate one you just need to add the permissions that you want to request for graph to the package-solution.json in the webApiPermissionRequests section and then get a SharePoint Admin to approve the api (if it's not already approved) in the SharePoint Admin center. Another option is to follow Andrew Connell's advice and skip the declarative permissions and use either PowerShell or the CLI for Microsoft 365 to grant permissions directly.

bhoomesh-spe commented 2 months ago

@juliemturner - Thank you again for the valuable feedback. When the email is sent with graph api it is sent from the current logged-in user email instead of no-reply@sharepointonline.com. If the current logged-in user doesn't have an Outlook license then the email functionality may not work. Is it correct?

bcameron1231 commented 2 months ago

@juliemturner - Thank you again for the valuable feedback. When the email is sent with graph api it is sent from the current logged-in user email instead of no-reply@sharepointonline.com. If the current logged-in user doesn't have an Outlook license then the email functionality may not work. Is it correct?

Correct.

patrick-rodgers commented 2 months ago

Closing this issue as answered. If you have additional questions or we did not answer your question, please open a new issue, ref this issue, and provide any additional details available. Thank you!

github-actions[bot] commented 1 month ago

This issue is locked for inactivity or age. If you have a related issue please open a new issue and reference this one. Closed issues are not tracked.