I have tried chaning this email code to a function but after running the script then trying to use the function " smtp-mail "email.address@domain.com" but get the error "is not recognized as a cmdlet, function, operable program"
function smtp-mail ([string]$to ="")
{
$SmtpClient = new-object system.net.mail.smtpClient
$MailMessage = New-Object system.net.mail.mailmessage
$SmtpClient.Host = "relay"
$mailmessage.from = ("test.email@domain.com ")
$mailmessage.To.add($to)
$mailmessage.Subject = "Test Email”
$mailmessage.Body = "Testing”
$smtpclient.Send($mailmessage)
}
<message edited by marcussmith on Friday, December 07, 2007 1:28 AM>