Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
cat=0#send-email-from-
powershell-example
https://www.enmimaquinafunciona.com/pregunta/64467/como-iniciar-powershell-desde-cmd-
por-la-ruta-de-acceso-especifica
https://enavas.blogspot.com/2017/05/ejecutar-script-de-powershell-desde-la.html
https://sobrebits.com/enviar-correo-desde-powershell/
Param(
[string]$sender,
[string]$address,
[string]$name,
[string]$body
)
[reflection.assembly]::LoadFile("C:\Program Files
(x86)\EASendMail\Lib\net20\EASendMail.dll")
$mail.Subject = $subject
if($htmlFormat) {
$mail.HtmlBody = $body
}
else {
$mail.TextBody = $body
}
# If your 25 port is blocked by ISP, you can try to use 587 port
$server.Port = 587
# Using TryTLS,
# If smtp server supports TLS, then TLS connection is used; otherwise, normal
TCP connection is used.
# https://www.emailarchitect.net/easendmail/sdk/?ct=o_smtpconnecttype
$server.ConnectType = [EASendMail.SmtpConnectType]::ConnectTryTLS
# If your server is Exchange 2007 or later version, you can use EWS protocol.
# https://www.emailarchitect.net/easendmail/sdk/?ct=o_serverprotocol
# Set Exchange Web Service Protocol - EWS - Exchange 2007/2010/2013/2016
# $server.Protocol = [EASendMail.ServerProtocol]::ExchangeEWS
function SendMailFromPowerShell () {
#$sender = "efdomador@gmail.com"
#$name = "PowerShell"
#$address = "efdomador@gmail.com"
$subject = "Test email from Powershell"
#$body = "This is a test email from Powershell"
try {
"Start to send email to {0} ..." -f $address
SendMailTo $sender $name $address $subject $body ""
"Email to {0} ha sido enviado!" -f $address
}
catch [System.Exception] {
"Ha fallado el envio de email: {0}" -f $_.Exception.Message
}
}
SendMailFromPowerShell