MSExchangeGuru.com

Learn Exchange the Guru way !!!

 

Using Powershell to generate read receipts for emails

I recall using ASP.NET to enumerate a work flow to send emails and request a Read Receipt. Let’s look at how to achieve similar results using PowerShell.

The following PowerShell script will monitor all databases and report their Status if Mounted.

You can change “Mounted” to “Dismounted” in the Subject and cmdlet line to monitor “Dismounted’ databases

# Specify Sender, Recipient, Subject and Server
                  $From = "Admin@contoso.com"
                   $To = " ratish@contoso.com"
                   $Subject = "All Mounted Mailbox Databases"
                   $Server = "relayservername"
# Construct the Email
                   $Email = New-Object System.Net.Mail.MailMessage $From, $To
                   $Email.Subject = $Subject
                   $Email.IsBodyHTML = $True
# Request Read Receipt
                   $Email.Headers.Add(“Disposition-Notification-To”, “ratish@contoso.com”)
# Add the script or input cmdlet
                   $Email.Body = Get-MailboxDatabaseCopyStatus * | where {$_.Status -Like "Mounted"} | Select-Object Name,Status | ConvertTo-Html
# Send the Email
                   $Compose = New-Object Net.Mail.SmtpClient($Server)                  
                   $Compose.Send($Email)

Ratish Nair

Microsoft MVP | Exchange Server

Team @MSExchangeGuru.com

Leave a Reply

Categories

Archives

MSExchangeGuru.com