Generate Channel email address with GraphApi

Copper Contributor



I'm trying to generate Channel's email through GraphApi.

It works well when I'm a member of the Teams but when I try to generate one with a Team/Channel, I'm not member of, I receive a weird error "Bad Request"


I've tried through "Application Context" and "Delegate Context" but still not working.  (New-MgTeamChannelEmail can't be use in Application Context though)




$myAccessToken = Get-MsalToken -ClientId $clientID -TenantId $tenantID -Scopes '' -RedirectUri ''
# $myAccessToken = Get-MsalToken -ClientId $clientID -TenantId $tenantID -ClientSecret $clientSecret -Scopes '' -RedirectUri ''
$token = $myAccessToken.AccessToken
Connect-MgGraph -AccessToken $token

# Set the baseurl to MS Graph-API (BETA API)
$baseUrl = ''
# Pack the token into a header for future API calls
$header = @{
          'Authorization' = "Bearer $($Token)"

# write-host $userPurpose.value
$generatedemail = New-MgTeamChannelEmail -TeamId $TeamId  -ChannelId $ChannelId 



Any ideas ?


3 Replies
As clearly stated in the documentation, application permissions are not supported for this operation:

Use delegate permissions, and make sure the user you're running under has enough permissions (being a member of the Team is usually enough).

Exactly! that's why I'm using User Context instead... The problem is that I'm not a member of all the teams, I need to generate the mail for...
Do I need to add the account to all the teams before generating the email ?

Afaik that's the only way.