Friday, March 25, 2016

SharePoint PowerShell CSOM send email

In my previous article I explained about reading a SharePoint list using SharePoint PowerShell CSOM. In this article I will simply explain how to send an email using SharePoint PowerShell CSOM. 

In order to do this, you need to have the PowerShell CSOM setup done as I have explained in my previous article

An email can be simply sent using the SendMail method of the Utility class through the following code.

$email = [String[]]($email_receiver)
$emailProperties = New-Object Microsoft.SharePoint.Client.Utilities.EmailProperties
$emailProperties.To = $email
$emailProperties.Subject = $email_subject
$emailProperties.Body = $Body
[Microsoft.SharePoint.Client.Utilities.Utility]::SendEmail($Context,$emailProperties)


Used variables along with the description are as follows.

  • $email_receiver - Received email address. This needs to be an email of a user within the organization as we are using the SendEmail method.
  • $email_subject - Subject of the email.
  • $Body - Body of the email.
  • $email - This needs to be an array contains at least one element.


No comments:

Post a Comment