Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

Solution for my script please :SENDING SMTP EMAIL WITH POWERSHELL

$
0
0

Hello,

 

I am writing to you following a complication of error of my script,

 

The goal is to send the report by email of my script, I receive errors, is that you have an idea about this error please or a script that sends the email.

Thank you a lot.

#part send email:

#$PSEmailServer = "172.20.20.1"
#send-mailmessage -to "achraf@free.fr" -from "alerte@free.fr" -subject "Test mail" -SmtpServer 172.20.20.1

param(
[string]$to,
[string]$subject,
[string]$body
)
$smtpServer = "172.20.20.1"
$smtpFrom = "achraf@free.fr"
$smtpTo = "alerte@free.fr"
$messageSubject = $subject
$messageBody = $body
$smtp = New-Object Net.Mail.SmtpClient($smtpServer)
$smtp.Send($smtpFrom,$smtpTo,$messagesubject,$messagebody)

 


Viewing all articles
Browse latest Browse all 6937

Trending Articles