O365 Shared Mailbox sent items

By default, when “sending as” a shared mailbox, the sent items go into the users sent items folder. Unfortunately, it is not possible to change this to be the shared mailbox, but it is possible to put a copy in the shared mailbox’s sent items folder.

The below script will enable this for all shared mailboxes, so a copy will go into the sent items of the shared mailbox, whether the mail was sent using “send as” or “Sent on behalf”

connect-exchangeonline -UserPrincipalName [email protected]
$mailboxes = get-mailbox -resultsize unlimited -RecipientTypeDetails SharedMailbox
foreach ($mailbox in $mailboxes){
    $pct = [math]::Round((100/($mailboxes | measure-object).count) * $prog,2)
    Write-Progress -Id 1 -Activity "Working on " -status "$pct % Complete:" -PercentComplete $pct -CurrentOperation $mailbox.DisplayName
    write-host "trying " $mailbox.DisplayName -ForegroundColor Green
    set-mailbox $mailbox.displayname -MessageCopyForSentAsEnabled  $True
    set-mailbox $mailbox.displayname -MessageCopyForSendOnBehalfEnabled $True}
    write-host "An error occured on " $mailbox.DisplayName -ForegroundColor red


Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.