param ([switch]$configure)
$Date = Get-Date
$Server = gc env:computername
Create e-mail message
$msg = new-object Net.Mail.MailMessage
Set e-mail properties
$msg.subject = $Subject
Set e-mail body
$msg.body = $Body
Creating SMTP server object
$SMTP = new-object Net.Mail.SmtpClient($SMTPServer)
Email structure
$msg.From = "[email protected]"
$msg.Replyto = "[email protected]"
$Subject = "Hardware Alert from $Server $Date"
$SMTPServer = "smtp.office365.com"
$SMTPPort = '25'
$SMTPUser = '[email protected]'
$SMTPPassword = 'password'
body
else{$smtp.Send($msg)}
I keep getting "a recipient must be specified" when I run this. What am I doing incorrectly?