Powershell has great functionalities. One of those is the sendmail function. We used it like a timer job for reminding people to do something special. We built a small script which checks certain list items in SharePoint and fetches the title, the create date and the author. If the item is older than 30 days, the author gets a reminder to do a task on the item.
The powershell is stored as scheduled task in windows. But i’d like to share the sendmail function with you.
$to = "email@example.com" $subject = 'Subject Text' $body = 'Body Text' #SMTP server name (which is configured in SharePoint) $smtpServer = "SMTPServer" #Creating a Mail object $msg = new-object Net.Mail.MailMessage #Creating SMTP server object $smtp = new-object Net.Mail.SmtpClient($smtpServer) #Email structure $msg.From = "firstname.lastname@example.org" $msg.To.Add($to.Email) $msg.subject = $subject $msg.body = $body $msg.isBodyHTML = $true #Sending email $smtp.Send($msg)
That’s it. Now you can put some values from the list into the body or subject or even the receiver address (to). Enjoy it.