Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # This script will send an E-mail.
- # Send the script -to, -subject parameter followed by -body parameter.
- $filename = "C:\Path\to\file\name.txt"
- $smtpserver = "smtp.gmail.com"
- $msg = new-object Net.Mail.MailMessage
- # $att = new-object Net.Mail.Attachment($filename)
- $smtp = new-object Net.Mail.SmtpClient($smtpServer )
- $smtp.EnableSsl = $True
- $smtp.Credentials = New-Object System.Net.NetworkCredential("username", "password"); # Put username without the @GMAIL.com or – @gmail.com
- $msg.Subject = "Email Subjetc"
- $msg.Body = (Get-Content $filename ) -join "<BR>"
- $msg.IsBodyHTML = $true
- # $msg.Attachments.Add($att)
- $smtp.Send($msg)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement