Share via

Facing issue while sending invite using Microsoft Graph API With spfx react

Anonymous
2024-05-02T13:04:36.6366667+00:00

I am using the below code to sending invite but facing issues while sending email.

can someone help me to identify the issue

  public SendInvitationtoExternalUsers = async (ExternalUserEmail, ID): Promise<[]> => {
        this._graphClient = await this.spcontext.msGraphClientFactory.getClient(); //TODO       
        let InvitaitonSuccessData: [] = [];
        try {
            const InvitationResponse = await this._graphClient.api(`/invitations`).version('v1.0').post({
                "invitedUserType": "Guest",
                "sendInvitationMessage": true,
                "invitedUserEmailAddress": "" + ExternalUserEmail + "",

                 "inviteRedirectUrl": "https://demotenant.sharepoint.com/sites/samplepage.aspx?Guestinvitations=true&RequestType=New&ViewID="+ID+"&env=WebView", 
                "invitedUserMessageInfo": {
                    "customizedMessageBody": "Greetings from tenant !!! Thank you for joining with us."
                }
            });
           
            InvitaitonSuccessData = InvitationResponse.value as [];
        } catch (error) {
            console.log('Unable to sent invitation to external user', error);
        }
        return InvitaitonSuccessData;
    }


Microsoft 365 and Office | SharePoint | For business | Windows
Microsoft Security | Microsoft Graph

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.