functions/mailItems/Invoke-EXRUnsubscribeEmail.ps1
function Invoke-EXRUnsubscribeEmail { [CmdletBinding()] param ( [Parameter(Position = 0, Mandatory = $false)] [string] $MailboxName, [Parameter(Position = 1, Mandatory = $false)] [psobject] $AccessToken, [Parameter(Position = 2, Mandatory = $false)] [psobject] $ItemRESTURI ) Process { if($AccessToken -eq $null) { $AccessToken = Get-ProfiledToken -MailboxName $MailboxName if($AccessToken -eq $null){ $AccessToken = Get-EXRAccessToken -MailboxName $MailboxName } } if([String]::IsNullOrEmpty($MailboxName)){ $MailboxName = $AccessToken.mailbox } $HttpClient = Get-HTTPClient -MailboxName $MailboxName $RestURI = $ItemRESTURI + "/unsubscribe" return Invoke-RestPost -RequestURL $RestURI -HttpClient $HttpClient -AccessToken $AccessToken -MailboxName $MailboxName -Content "" } } |