how to send batch file by email code example
Example: send email using batch file script
$Username = $args[0]
$EmailPassword = $args[1]
$Username = $Username
$EmailTo = "[email protected]"
$EmailFrom = "[email protected]"
$Subject = "Email Subject"
$Body = "Email Body"
$SMTPServer = "smtp.gmail.com"
$SMTPMessage = New-Object System.Net.Mail.MailMessage($EmailFrom, $EmailTo, $Subject, $Body)
$SMTPClient = New-Object Net.Mail.SmtpClient($SmtpServer, 587)
$SMTPClient.EnableSsl = $true
$SMTPClient.Credentials = New-Object System.Net.NetworkCredential($Username, $EmailPassword);
$SMTPClient.Send($SMTPMessage)