Nothing new here, just a repost by popular demand... 

We need an SMTP Client object and a Mail Message object:

$SmtpClient = new-object system.net.mail.smtpClient

$MailMessage = New-Object system.net.mail.mailmessage

Then a basic configuration of their properties (you may have to adapt to fit you environment’s needs)

$SmtpClient.Host = "mysmtpserver.mycompany.local"

$mailmessage.from = "notification-services@mycompany.local"

$mailmessage.To.add("itadmins@mycompany.local")

$mailmessage.Subject = “Daily Uptime Reports”

$mailmessage.Body = “Server01. mycompany.local: 99.999% uptime”

And now, the special touch that makes Outlook display the message with a “bell” icon à la SharePoint notification:

$mailmessage.Headers.Add("message-id", "<3BD50098E401463AA228377848493927-1>") 

All you need is to add 3BD50098E401463AA228377848493927 before the actual message ID and separate them with a dash  And then send the message

$smtpclient.Send($mailmessage)

If you want your email to look even more eye-candy, enabled and add HTML to the body before sending

$mailmessage.IsBodyHtml = 1

You can even read from a file using get-content and generate the body

$mailmessage.Body = Get-Content .\report.html

Find more information over here:

And cut!


Posted in: PowerShell , Messaging  Tags:
Disclaimer
The information of this site is provided "AS IS" with no warranties, and confers no rights. This site does not represent the thoughts, intentions, plans or strategies of our employers, customers, friends or family. It is solely our own personal opinions. All code samples, scripts or configuration files are provided "AS IS" without warranty of any kind.

Limite de respnsabilité
Le contenu de ce site est délivré "TEL QUEL" et ne confère aucun droit ni garantie. Ce site ne reflète en aucun cas les pensées, intentions, projets ou stratégies de nos employeurs, clients, amis ou membre de nos familles. Il est uniquement l’expression de nos opinions personnelles. Les échantillons de codes, scripts ou fichiers de configuration sont fournis "TEL QUEL", sans la moindre garantie d’aucune sorte.