Send on behalf of shared mailbox
To send an email on behalf of a shared mailbox, you'll need to use the SendOnBehalfOf
parameter in the Send-MailMessage
cmdlet in PowerShell. Here's an example:
$sharedMailbox = "[email protected]"
$fromAddress = "[email protected]"
$subject = "Test email sent on behalf of shared mailbox"
$body = "This is a test email sent on behalf of the shared mailbox."
Send-MailMessage -To "[email protected]" -From $fromAddress -Subject $subject -Body $body -SmtpServer "smtp.example.com" -UseSsl -Credential (Get-Credential $sharedMailbox) -SendOnBehalfOf $sharedMailbox
In this example, replace:
$sharedMailbox
with the email address of the shared mailbox you want to send the email on behalf of.$fromAddress
with your own email address.[email protected]
with the email address of the recipient you want to send the email to.smtp.example.com
with the SMTP server you want to use to send the email.[email protected]
with your own email address.
Make sure to replace the placeholders with the actual values and run the command in PowerShell.
Note: You need to have the necessary permissions to send emails on behalf of the shared mailbox. Also, the Get-Credential
cmdlet is used to prompt you for the credentials of the shared mailbox. You can also hardcode the credentials if you have them.
Also, you can use the Send-MailMessage
cmdlet in Exchange PowerShell, it's more powerful and flexible than the one in Windows PowerShell.
$sharedMailbox = "[email protected]"
$fromAddress = "[email protected]"
$subject = "Test email sent on behalf of shared mailbox"
$body = "This is a test email sent on behalf of the shared mailbox."
Send-MailMessage -To "[email protected]" -From $fromAddress -Subject $subject -Body $body -SmtpServer "smtp.example.com" -UseSsl -Credential (Get-Credential $sharedMailbox) -SendOnBehalfOf $sharedMailbox -UseActAs
The -UseActAs
parameter is used to specify that the email should be sent on behalf of the shared mailbox.