When creating Microsoft 365 groups via the Microsoft Graph SDK, you might want to prevent the system from sending the default Welcome Email to users added as members of the group. This is useful for scenarios where a more tailored or controlled onboarding communication process is in place. Thankfully, Microsoft Graph provides a way to do this using the resourceBehaviorOptions
property.
Here’s a quick guide to adding this setting to your group definition when creating a site.
Adding the Welcome Email Disabled Setting
To disable the Welcome Email, you’ll include the resourceBehaviorOptions
property in your group creation code. In the Microsoft Graph .NET SDK, this is done by using the AdditionalData
property of the Group
object.
Below is the snippet that disables the Welcome Email:
AdditionalData = new Dictionary<string, object>
{
{ "resourceBehaviorOptions", new List<string> { "WelcomeEmailDisabled" } }
}
Here’s how you integrate it into a full group creation example:
using Microsoft.Graph;
using Microsoft.Identity.Client;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
class Program
{
static async Task Main(string[] args)
{
var clientId = "YOUR_CLIENT_ID";
var clientSecret = "YOUR_CLIENT_SECRET";
var tenantId = "YOUR_TENANT_ID";
var confidentialClientApplication = ConfidentialClientApplicationBuilder
.Create(clientId)
.WithClientSecret(clientSecret)
.WithAuthority($"https://login.microsoftonline.com/{tenantId}")
.Build();
var authProvider = new ClientCredentialProvider(confidentialClientApplication);
var graphClient = new GraphServiceClient(authProvider);
var newGroup = new Group
{
DisplayName = "Paris Employees",
MailNickname = "Paris.Employees",
Description = "Employees working in the Paris region",
GroupTypes = new List<string> { "Unified" },
MailEnabled = true,
SecurityEnabled = false,
AdditionalData = new Dictionary<string, object>
{
{ "resourceBehaviorOptions", new List<string> { "WelcomeEmailDisabled" } }
}
};
var createdGroup = await graphClient.Groups.Request().AddAsync(newGroup);
Console.WriteLine($"Created Group: {createdGroup.DisplayName}, ID: {createdGroup.Id}");
}
}
Key Points to Note:
- The
resourceBehaviorOptions
property is part of the additional data dictionary in the Microsoft Graph SDK. - Setting the value to
WelcomeEmailDisabled
ensures that no Welcome Email is sent to new members added to the group. - This property must be included during group creation. It cannot be updated for existing groups.
When to Use This Setting
This feature is particularly helpful when:
- You want to control the communication flow with new group members.
- Automated Welcome Emails do not align with your organizational policies.
- You’re integrating the group creation process with other systems that handle onboarding communications.
By using the resourceBehaviorOptions
setting, you can create groups that respect your communication preferences, ensuring a smooth and tailored user experience.