-
StackOverflow 文档
-
PowerShell 教程
-
发送电子邮件
-
SMTPClient - 正文邮件中带有 .txt 文件的邮件
# Define the txt which will be in the email body
$Txt_File = "c:\file.txt"
function Send_mail {
#Define Email settings
$EmailFrom = "source@domain.com"
$EmailTo = "destination@domain.com"
$Txt_Body = Get-Content $Txt_File -RAW
$Body = $Body_Custom + $Txt_Body
$Subject = "Email Subject"
$SMTPServer = "smtpserver.domain.com"
$SMTPClient = New-Object Net.Mail.SmtpClient($SmtpServer, 25)
$SMTPClient.EnableSsl = $false
$SMTPClient.Send($EmailFrom, $EmailTo, $Subject, $Body)
}
$Body_Custom = "This is what contain file.txt : "
Send_mail