Hi @Roger Roger ,
Welcome to the Microsoft Q&A platform!
It looks like you're on the right track with your script, but there are a few areas to check and adjust.Here are some specific suggestions:
- Ensure the path to the EWS Managed API DLL is correct and accessible:
$EWSServicePath = 'C:\Temp\EWS\bin\Debug\Microsoft.Exchange.WebServices.dll'
Import-Module $EWSServicePath
- Verify that the impersonation is correctly set up and that the shared mailbox allows impersonation:
$service.ImpersonatedUserId = New-Object Microsoft.Exchange.WebServices.Data.ImpersonatedUserId([Microsoft.Exchange.WebServices.Data.ConnectingIdType]::SMTPAddress, $MeetingMBX)
- Ensure the forwarding logic is correctly implemented and that the email addresses are valid:
foreach ($item in $FutureMeetings) {
$forwardMessage = New-Object Microsoft.Exchange.WebServices.Data.EmailMessage($service)
$forwardMessage.Subject = "Fwd: " + $item.Subject
$forwardMessage.Body = $item.Body
foreach ($recipient in $emaillist) {
$forwardMessage.ToRecipients.Add($recipient)
}
$forwardMessage.SendAndSaveCopy()
}
- Ensure the logging is correctly implemented:
"Date: $Now" | Out-File ".\FWReport.csv" -Append
"Addresses: $emaillist" | Out-File ".\FWReport.csv" -Append
"Subject: $item.Subject" | Out-File ".\FWReport.csv" -Append
"Start: $item.Start" | Out-File ".\FWReport.csv" -Append
"End: $item.End" | Out-File ".\FWReport.csv" -Append
"Location: $item.Location" | Out-File ".\FWReport.csv" -Append
"--------------------------------------------------------------" | Out-File ".\FWReport.csv" -Append
- Ensure the script is correctly scheduled in Task Scheduler with the necessary permissions.
Please feel free to contact me for any updates. And if this helps, don't forget to mark it as an answer.
Best,
Jake Zhang