#####################################
function SendMail([string]$TextToSend)
{
$filename = "filename.txt"
$smtpServer = "SmtpServerName"
$msg = new-object Net.Mail.MailMessage
$att = new-object Net.Mail.Attachment($filename)
$smtp = new-object Net.Mail.SmtpClient($smtpServer)
[string]$tempFrom = $env:computername + ' <' + $env:computername + "@" + $env:userdomain + ".COM>"
$tempFrom $msg.From = $tempFrom
$msg.To.Add("sendto@domain.com")
$msg.Subject = "Subject"
$msg.Body = $TextToSend$msg.Attachments.Add($att)
$smtp.Send($msg)
$msg.dispose()
}
#####################################
Ingen kommentarer:
Send en kommentar