Search code examples
javascripttypescriptnext.jsmicrosoft-graph-api

Msgraph user Invite custom email template


all im trying to figure out is if its possible to make a email template for the msgraph api. im inviting users to my azure and that sends them a email but its not a very pleasing email.

  public async sendUserInvite(body: {email: [email protected]}) {
    await this.client.api('/invitations').post({
      invitedUserEmailAddress: body.email,
      inviteRedirectUrl: `http://localhost:3000/`,
      sendInvitationMessage: true
    })
  }

this is the api that sends a invite email to the user. i have searched the whole web but couldnt find anything so hope to get some answers here :P


Solution

  • There should the property invitedUserMessageInfo where you can setup a customized message, but I'm not sure whether the customizedMessageBody property supports only plain text or html.

    public async sendUserInvite(body: {email: [email protected]}) {
      await this.client.api('/invitations').post({
       invitedUserEmailAddress: body.email,
       inviteRedirectUrl: `http://localhost:3000/`,
       sendInvitationMessage: true,
       invitedUserMessageInfo: {
         messageLanguage: 'en-US',
         customizedMessageBody: 'Your message'}
       })
    }