-
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