Kanchana_Silva
asked on
Script to find Daily receive emails
Hello,
I want to ran an script on schedule basis to get one recipient's daily's receive email then send to his email address.
Get-MessageTrackingLog -Start (Get-Date).adddays(-1) -ResultSize unlimited -Recipients user1@contoso.com | select-object Sender, MessageSubject, Timestamp | ConvertTo-Html | Out-File E:\Report\report.html
I want to above cmdlet run on the task schedule on end of the day and send email to recipient.
I want to ran an script on schedule basis to get one recipient's daily's receive email then send to his email address.
Get-MessageTrackingLog -Start (Get-Date).adddays(-1) -ResultSize unlimited -Recipients user1@contoso.com | select-object Sender, MessageSubject, Timestamp | ConvertTo-Html | Out-File E:\Report\report.html
I want to above cmdlet run on the task schedule on end of the day and send email to recipient.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Please try the below steps and let me know the results.
1. Store the above cmdlet in a .ps1 file.
2. Open notepad and type the below command (without wordwrap)
PowerShell.exe -PSConsoleFile "<exchange installation drive>\Exchsrvr\Bin\ExShel
This command will invoke the exchange management shell first and then run the .ps1 file.
eg:
PowerShell.exe -PSConsoleFile "D:\Microsoft\Exchsrvr\Bin
Save the notepad as a batch file (.bat)
3. Now open task scheduler and select create basic task.
Provide a name and proceed next --> choose daily and click next --> select the time you want the task to be executed --> in action select 'start a program' and click next --> in the program/script box, browse and provide the .bat file that was saved and click finish.
Check whether the task is running as scheduled.
To send this report as an email, you will have to write a separate script and schedule it to run after this task completes and then add the attachment to it.
Kindly revert back.