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

Thursday, March 24, 2016

Client-side SharePoint PowerShell CSOM Read list

SharePoint PowerShell API provides the capability to connect to SharePoint 2010, 2013 and Online. The major advantage is that these can be run from a remote machine. The API is available in CodePlex.

I will focus on how to use the API and read a SharePoint list in this article.

First we need to download the source from CodePlex and extract it to a directory with necessary permissions. I am using 'C:\SPPS\Source' as the location for extraction.

Next we need to get a client context as in a normal CSOM.

Wednesday, March 16, 2016

C# CSOM SharePoint Online Authentication

SharePoint Online authentication via C#.NET Client-side Object Model is simplified with the SharePointOnlineCredentials class. Usage of this has been explained in Vardhaman Deshpande's blog. Usage of this within a Windows Phone app and exception handling is explained in this article.

I have attempted this within a console application as well as in a Windows Phone 8.1 App built using Visual Studio 2013 with Update 5. Basically it will work within Universal Apps.

  • When using the Console Application you need to reference the Microsoft.SharePoint.Client assembly.
  • In order to use this within the Windows Phone Application you need to reference the Microsoft.SharePoint.Client.Runtime assembly. 

The code sample is as follows, in order to proceed with operations, you need to follow the context load and execute query model.

Monday, March 14, 2016

C# CSOM SharePoint authenticating Online and On-Premises

Recently I had the need to implement an authentication scenario for both SharePoint Online and SharePoint 2013. The authentication credentials for both scenarios are handled through different classes within different namespaces. First, let me share the two code samples for both.