When you post code or error messages or sample data or console output format it as code, please.
In the “Text” view you can use the code tags “PRE”, in the “Visual” view you can use the format template “Preformatted”. You can go back edit your post and fix the formatting - you don’t have to create a new one.
Thanks in advance.
How are you planning to execute the script, via taskscheduler ?
You can always use Get-ChildItem which will have the Datecreated property and use that property to compare against the current date to decide wither to send success or failure message. And to pick the addresses from a txt file(one recipient in a line), you would use Get-Content cmdlet then pass it to th -To parameter of Send-MailMessage cmdlet.
You don’t need to use Net.Mail.MailMessage class, instead use Send-MailMessage cmdlet. The detailed help for above cmdlets below
This was super helpful, I was able to easily implement my idea with the help.
now for the second part, hopefully you see this im unsure how notifications work on this site but if I wanted to email all emails that were in a .txt file would I set it up like this
$bcclist = Get-content 'E:\list.txt
and then for the to would I just do
to = ‘$bcclist’
would that send it to all of them? the txt file has the listed like this:
Please read my first answer again … completely … not just the code suggestion i posted.
Great. I hope you don’t just use the code. I hope you try to understand what exactly it does.
Instead of an answer with a piece of code ready to use I’d like to encourage you to do your own research and try to solve your problem yourself. You might have already heard about the method “Trial and Error”. Plesae always read the help for the cmdlets you’re about to use including the examples to learn how to use them. And if you got stuck with your code you can come back and we will try to help you.