Skip to content

Instantly share code, notes, and snippets.

@M0H4MM33D
Created April 27, 2018 15:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save M0H4MM33D/7380f89b80995b8ca3ec11e5b0f2b257 to your computer and use it in GitHub Desktop.
Save M0H4MM33D/7380f89b80995b8ca3ec11e5b0f2b257 to your computer and use it in GitHub Desktop.
Send auto rapport cvs or txt or .. to mail using powershell (ATTACHMENT FILE).
$x=GET-Date
$t7en = "C:\Users\Administrateur\Desktop\rapport.csv"
$smtpServer = "smtp.gmail.com"
$sender = "EMAIL SERNDER"
$users = "EMAIL RCP";
$subject = "Rapport at $x"
$body = "By M0H4MM3D"
$message = new-object System.Net.Mail.MailMessage
$message.From = $sender
$message.To.Add($users)
$message.IsBodyHtml = $True
$message.Subject = $Subject
$attach = new-object Net.Mail.Attachment($t7en)
$message.Attachments.Add($attach)
$message.body = $body
Write-Host "Sending email notification to $user" -ForegroundColor Green
$smtp = New-Object Net.Mail.SmtpClient($smtpServer, 587)
$smtp.EnableSsl = $true
$smtp.Credentials = New-Object System.Net.NetworkCredential("USER@gmail.com", "PASSWORD");
$smtp.Send($message)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment