You could use script below to check it:
$mailbox = Get-Mailbox -ResultSize unlimited -RecipientTypeDetails RoomMailbox | where{$_.WhenMailboxCreated -gt (get-date).AddHours(-24)} | select Name
If ($Mailbox -eq $null){
$Subject = "No Room Mailbox created within 24 hours"
}Else{
$body =""
$Subject = "Mailboxes Created within 24 hours"
foreach ($item in $mailbox) {
$body = $body + $item.name + " "
}
}
$From = "TestUser@domain.com"
$password = "1234"
$To = "TestUser2@domain.com"
$smtpServer = "mail.domain.com"
$smptport= '587'
$SMTPMessage = New-Object System.Net.Mail.MailMessage($From, $To,$Subject,$Body)
$SMTPClient = New-Object System.Net.Mail.SmtpClient($smtpServer, $SmtpPort)
$SMTPClient.EnableSsl = $true
$SMTPClient.Credentials = New-Object System.Net.NetworkCredential($From, $password);
$SMTPClient.Send($SMTPMessage)
You need to edit the 13~16 lines before using it.
If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.