美好的一天!请帮助,请在此处使用此脚本:
$file = "C:\Reports\Log_1.txt"
$FileExists = Test-Path $file
If ($FileExists -eq "False") {
Write-Host "sending mail"
$mail = New-Object System.Net.Mail.MailMessage
$mail.From = New-Object System.Net.Mail.MailAddress("test@gmail.com")
$mail.To.Add("test@gmail.com")
$mail.Subject = "report";
$mail.Body = get-content $file
$smtp = New-Object System.Net.Mail.SmtpClient
$smtp.host = "smtp.domen.com"
$smtp.port="25"
$Credentials = new-object System.Net.networkCredential
$Credentials.domain = "smtp.domen.com"
$Credentials.UserName = "test@gmail.com"
$Credentials.Password = "rgrthbdgfhytju"
$smtp.Credentials = $Credentials
$smtp.Send($mail)
}
# else {
#Write-Host "File $file not found"
#}
尝试连接两台邮件服务器时遇到两个错误。 在第一种情况下,连接错误和第二个身份验证错误:
错误2(公司帖子):使用此1参数调用异常失败发送邮件。
抱歉,我无法插入限制图片。