Menu

[ea00bd]: / email-google / Sample.ps1  Maximize  Restore  History

Download this file

21 lines (18 with data), 852 Bytes

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
#
# snippet courtesy Josh German
#
# source slack: https://join.slack.com/t/ninjarmm-colab/shared_invite/enQtNDczNDQxMTE1MTM3LWY3ZjYwMTFhYzE0NjE3M2YzMDkxNGNhOTVjNzFkMjk1MGZmZjQzM2RiN2JjYWE2ZjVmNjg4MTQ3ZTJmMzVlODU
#
$EmailTo = "josh@blah.net"
$EmailFrom = "josh@blah.net"
$Subject = "Email Subject"
$Body = "Computer name - $env:computername"
$SMTPServer = "smtp.office365.com"
$filenameAndPath = "C:\omeDir\someFile.pdf"
$SMTPMessage = New-Object System.Net.Mail.MailMessage($EmailFrom,$EmailTo,$Subject,$Body)
$attachment = New-Object System.Net.Mail.Attachment($filenameAndPath)
$SMTPMessage.Attachments.Add($attachment)
$SMTPClient = New-Object Net.Mail.SmtpClient($SmtpServer, 587)
$SMTPClient.EnableSsl = $true
$SMTPClient.Credentials = New-Object System.Net.NetworkCredential($EmailFrom, "supersecretpassword");
$SMTPClient.Send($SMTPMessage)
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.