I have a provisioning engine in C# that creats new MS Teams with MS Graph. Whenever a user is added to a Team (inside the Teams Client) he gets 2 invitation mails - one for the O365 Group and one for Teams itself.
The O365 Group Mail was disabled via custom Code (ResourceBehaviorOptions -> WelcomeEmailDisabled) taken from the PnP Core Unified Groups Utility:
class ExtendedO365Group : Microsoft.Graph.Group
{
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore, PropertyName = "resourceBehaviorOptions")]
public string[] ResourceBehaviorOptions { get; set; }
[JsonProperty("owners@odata.bind", NullValueHandling = NullValueHandling.Ignore)]
public string[] OwnersODataBind { get; set; }
[JsonProperty("members@odata.bind", NullValueHandling = NullValueHandling.Ignore)]
public string[] MembersODataBind { get; set; }
}
[...]
var newGroup = new ExtendedO365Group
{
DisplayName = displayName,
Description = description,
MailNickname = mailNickname,
MailEnabled = true,
SecurityEnabled = false,
Visibility = isPrivate == true ? "Private" : "Public",
GroupTypes = new List<string> { "Unified" },
ResourceBehaviorOptions = (disableWelcomeMail ? new string[] { "WelcomeEmailDisabled" } : null)
};
Inspired by this Graph Issue.
And then later the Teams Team is added to the Group, but there seems to be no setting or property to disable mailing inside Teams.
I also know about this PowerShell Command, which does the same thing afaik
Set-UnifiedGroup -Identity "groupname" -UnifiedGroupWelcomeMessageEnable:$false
And tried to disable Mailing with
MailEnabled = false,
But all of this disables only the first mail, sent from the O365 Group with the Subject "User xy has added you to the Group yz" (roughly translated from German) and a link to the Outlook Group. It does not disable the second mail from Teams "You have been added to a team in Microsoft Teams" with a link to open it in the Teams Client.
Is there some new Graph Property or C# command that will disable ALL invitation mails? If nothing else works I would try to integrate a PowerShell command if there is one that works.
EDIT: It really seems that this is a bug as seen in this Uservoice and the accepted answer.