If somebody like the post and its helpful in your work then, add comments.

Monday, April 24, 2017

Office 365 : send email from SharePoint Online using CSOM PowerShell

Below script:

Add-Type -Path 'C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.dll'
Add-Type -Path 'C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.Runtime.dll'
$username = "[UserName]"
$securePassword = ConvertTo-SecureString "[Password]" -AsPlainText -Force
$spoCred = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($username, $securePassword)
$context = New-Object Microsoft.SharePoint.Client.ClientContext("[https://[XXXXXXXXXXXXXXXXXX]/")
$context.Credentials = $spoCred                                                                
$toEmail ="[Email1]","[Email2]"  
$toSubject ="[Subject]"
$toBody ="[BODY]"       

[String[]]$email =  $toEmail
$emailProperties = New-Object Microsoft.SharePoint.Client.Utilities.EmailProperties

write-host  $emailProperties
$emailProperties.To = $email
$emailProperties.CC = [String[]]("[Email]")
$emailProperties.From = "[Email]"
$emailProperties.Subject = $toSubject
$emailProperties.Body = $toBody

Windows PowerShell : Create Month folders

To create folder user below script in WINDOWS ISE.

$path ="[Path]\"
$months = "April 2018","May 2018","June 2018","July 2018","August 2018","September 2018","October 2018","November 2018","December 2018","January 2019","February 2019","March 2019"
foreach($month in $months)
    New-Item -ItemType Directory -Path "$path$month"

Friday, November 6, 2015

SharePoint Office 365 ECMA : Get version of the List Item


To get version of the SharePoint list items; there are two option in JavaScript
  1. SPServices
            operation: "GetVersionCollection",
            async: false,
            strlistID: "Deviations",
            strlistItemID: DID,
            strFieldName: "PreventionDescription",
            completefunc: function (xData, Status) {
                // alert(xData.responseXML.xml)
                $(xData.responseText).find("Version").each(function () {
                        "Description": $(this).attr("PreventionDescription"),
                        "Editor": $(this).attr("Editor").split(",#")[4],
                        "Modified": $(this).attr("Modified"),
                        "Image": "/_layouts/15/userphoto.aspx?size=S&accountname=" + $(this).attr("Editor").split(",#")[3].toLowerCase().replace("@", "%40")
  1. ECMA 

  • var filePath = '/sites/dk/sites/Departments/qms/Lists/Deviations/' + DID + '_.000'
    var clientContext = new SP.ClientContext;
    //var oList = clientContext.get_web().get_lists().getByTitle('Deviations');
    var web = clientContext.get_web();
    var listItemInfo = web.getFileByServerRelativeUrl(filePath);
    var listItemFields = listItemInfo.get_listItemAllFields();
    clientContext.executeQueryAsync(function (sender, args) {
        var fileVersions = listItemInfo.get_versions();
        clientContext.executeQueryAsync(function (sender, args) {
            var fieldEnumerator = fileVersions.getEnumerator();
            while (fieldEnumerator.moveNext()) {
                var oListItemVersion = fieldEnumerator.get_current();

                // preventiveListTemp.push({

                // });


        }, onQueryFailed);

    }, onQueryFailed);
  • Friday, May 22, 2015

    SharePoint ECMA : Get pages library items in ECMA

    To get the pages library items,  using the JavaScript/JSOM. For that in the clientContext.load we have to pass "File" parameter and than the site columns(internal names)

    getNewsPages = function() {
                     var clientContext = new SP.ClientContext.get_current();
                    var oList = clientContext.get_web().get_lists().getByTitle('Pages');
                    var camlQuery = new SP.CamlQuery();
                    camlQuery.set_viewXml(" 50");
                    selectedDoc = oList.getItems(camlQuery);
                    clientContext.load(selectedDoc , 'Include(Id, Title,File,PublishedDate1,TeaserText,TeaserImage,FileRef,NewsFilter)');
                    clientContext.executeQueryAsync(gettingNewsPagesSuccess , onQueryFailed);

                gettingNewsPagesSuccess = function() {
                    var listItemEnumerator = selectedDoc.getEnumerator();
                    while (listItemEnumerator.moveNext()) {
                        var oListItem = listItemEnumerator.get_current();
                            "Id": oListItem.get_id(),
                            "Title": oListItem.get_item('Title') ,
                            "PublishedDate": oListItem.get_item('PublishedDate1'),
                            "TeaserText": oListItem.get_item('TeaserText') ,
                            "TeaserImage": oListItem.get_item('TeaserImage'),
                            "Path": oListItem.get_item('FileRef'),
                            "NewsFilter": oListItem.get_item('NewsFilter')


    Monday, March 2, 2015

    Office 365 : Create a site using custom site template

    To create a site using your designed custom site template in JSOM/ECMA, we can use below example :

     createProjectSite = function ($data) {
                dialogValue = SP.UI.ModalDialog.showWaitScreenWithNoClose("Site Creation", "Working on it...", 120, 400);
                var url = $data.Title.replace(/[^a-z0-9\s]/gi, '').replace(/[_\s]/g, '');
                currentProjectObject = $data;
                var clientContext = CORO.megaMenucontext;

                var WCI = new SP.WebCreationInformation();
                if ($data.Access == "Public") { WCI.set_useSamePermissionsAsParentSite(true); }//To inherit the permission
                if ($data.Access == "Closed") { WCI.set_useSamePermissionsAsParentSite(false); }//To break the permission
                newWeb = projectWeb.get_webs().add(WCI);
                //save changes and generate callbacks
                clientContext.executeQueryAsync(onCreationSuccess, onQueryFailed);

    Office 365 : How to update quick launch node in SharePoint 2013

    To update a navigation note in SharePoint quick lanuch, we can do by JSOM. In below example we are updating the red box node.
            collChildNavNode =null,
            getNavigationNode = function(web, listData)
                 var clientContext = CORO.megaMenucontext;
                // Get the Quick Launch navigation node collection.
                quickLaunchNodeCollection = web.get_navigation().get_quickLaunch();
            getNavigationNodeSuccess = function (sender, args) {
                var url = currentProjectObject .Title.replace(/[^a-z0-9\s]/gi, '').replace(/[_\s]/g, '');
                var clientContext = CORO.megaMenucontext;
                collChildNavNode = quickLaunchNodeCollection.get_item(0);     
                clientContext.executeQueryAsync(createNavNode ,onQueryFailed);
            createNavNode = function()
                var url = currentProjectObject .Title.replace(/[^a-z0-9\s]/gi, '').replace(/[_\s]/g, '');
                var clientContext = CORO.megaMenucontext;
                collChildNavNode.set_url("/sites/dk/sites/projects/" +url);       
                clientContext.executeQueryAsync(createNavNodeSuccess, onQueryFailed);
            createNavNodeSuccess = function()
                console.log("Created navigation node");

    Thursday, September 18, 2014

    SharePoint 2013 : Running the pre-requisite in Windows Server 2012 R2

    Well, when we want to start the installing SharePoint 2013 or SharePoint 2013 foundation in Windows Server 2012 R2 there is more often problem comes that the pre-requisite didn’t run in the in Windows Server 2012 R2 machine. There is due to because the pre- requisite is searching for the SeverManagerCmd.exe in Windows/System32 location, instead of that in R2 version the application name is SeverManager.exe.

    So, to run the pre-requisite in Windows Server 2012 R2, Copy the SeverManager.exe, and paste in the same location i.e Windows/System32 and rename to SeverManagerCmd.exe. Then run the pre-requisite application from SharePoint iso/disc/installer. It will work fine

    Friday, August 29, 2014

    SharePoint 2013 : How to open and close SP.UI.ModalDialog.showWaitScreenWithNoClose

    How to use SP.UI.ModalDialog.showWaitScreenWithNoClose to display custom loading message. Simplest way is that just write below code where you have to call the loader/model box of waiting

    var value = SP.UI.ModalDialog.showWaitScreenWithNoClose(title, message, height, width);
    and to close just add below code
    There are lost of option are also available, which can be seen on 

    Friday, August 1, 2014

    Yammer : How to get current logged in user unseen message count

    Well this is my first application of Yammer, I was wondering how to start on the application. So, first thing come in my mind that to explore the Yammer,

    What is yammer?

    How can we use it?

    What are the entities in yammer, which we can use or integrate in our application. etc

    So, logged in Yammer, created network added the people. So, now when all thing are up then for just creating a sample application a scenario occurs in my mind “current logged in user unseen message count”. How to start on the, where to deploy that????

    I added one more Technology my FAV one, SharePoint. Final scenario showing  current logged in user unseen message count in SharePoint online. Created a trial account in that and create on page. First I tried with yammer default feed JS code. It works find ….OK.

    So, for custom development I looked on Google and found the wonderful description on yammer API. How to consume in various domains, how add in various platforms. Link is below


    To get current logged in user unseen message count

        <h3 > Unseeen Messages</h3><div id="numberOfMessages"></div>
        <script type="text/javascript" src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
        <script type="text/javascript" data-app-id="[Your App ID]" src="https://assets.yammer.com/assets/platform_js_sdk.js"></script>

        <span id="yammer-login"></span>
        <script type="text/javascript" >
          function(response) {
            if (response.authResponse) {
                  console.log("logged in");            
                    url: "networks/current.json",
                    method: "GET",       
                    beforeSend: function (req) { //print message response information to the console
                    } ,
                    success: function (user) { //print message response information to the console
                        document.getElementById('numberOfMessages').innerHTML= user[0].unseen_message_count;
                    error: function (user) {
                      alert("There was an error with the request.");


    but before adding the above code we have to create on app in yammer




    remember this redirect URL should be match with your domain and JavaScript origin will be the URL of page where the JS or JS is rendering.

    Click Save


    This big bold highlighted one is the key point where I stuck an have goggling for like 2 days Smile