title: Disable MS Teams invitation mail via C#/Graph
body: <p>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.</p>
  
  <p>The O365 Group Mail was disabled via custom Code (ResourceBehaviorOptions -> WelcomeEmailDisabled) taken from the PnP Core Unified Groups Utility:</p>
  
  <pre><code>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&lt;string&gt; { "Unified" },
      ResourceBehaviorOptions = (disableWelcomeMail ? new string[] { "WelcomeEmailDisabled" } : null)
  };
  </code></pre>
  
  <p>Inspired by this <a href="https://github.com/microsoftgraph/msgraph-sdk-dotnet/issues/528" rel="nofollow noreferrer">Graph Issue</a>.</p>
  
  <p>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.</p>
  
  <p>I also know about this PowerShell Command, which does the same thing afaik</p>
  
  <pre><code>Set-UnifiedGroup -Identity "groupname" -UnifiedGroupWelcomeMessageEnable:$false
  </code></pre>
  
  <p>And tried to disable Mailing with</p>
  
  <pre><code>MailEnabled = false,
  </code></pre>
  
  <p>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.</p>
  
  <p>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.</p>
  
  <p>EDIT: It really seems that this is a bug as seen in <a href="https://microsoftteams.uservoice.com/forums/555103-public/suggestions/35391220-make-unifiedgroupwelcomemessageenabled-work-for-te" rel="nofollow noreferrer">this Uservoice</a> and the accepted answer.</p>