Total Pageviews

27 Dec 2013

Get all Items from a list avoiding treshold

 private static List<SPListItem> GetAllListItems(SPWeb web, SPList list)
            List<SPListItem> listItems  = new List<SPListItem>();
            SPQuery query = new SPQuery();
            SPListItemCollection spListItems;
            string lastItemIdOnPage = null;
            int itemCount = 2000;

            while (itemCount == 2000)
                query.ViewFieldsOnly = false;
                query.RowLimit = 2000;
                if (lastItemIdOnPage != null)
                    SPListItemCollectionPosition pos = new SPListItemCollectionPosition(lastItemIdOnPage);
                    query.ListItemCollectionPosition = pos;
                spListItems = list.GetItems(query);

                if (spListItems.ListItemCollectionPosition == null)

                lastItemIdOnPage = spListItems.ListItemCollectionPosition.PagingInfo;
                itemCount = spListItems.Count;
            return listItems;

19 Dec 2013

List of Useful SharePoint CSS Classes

When developing custom SharePoint solutions you can save a lot of time by taking advantage of the built-in CSS classes inside corev4.css or  corev15.css files.

For instance: you can use ms-error class in order to make your label red.
You can also use these:
.s4-clust - hides the element for the print view.

Here is a good list of ready-to-use CSS classes:

Unfortunately, this link does not contain the whole list of useful classes, but it's a good start anyway.

13 Dec 2013

Change "SharePoint" in ms-core-brandingtext

In case you were wondering how to change "SharePoint" text in the top left corner:

In SharePoint Management PowerShell:

$app = get-spwebApplication "http://mysite"
$app.SuiteBarBrandingElementHtml = "<div class='ms-core-brandingText'>Custom Brand</div>"


6 Dec 2013

Setting up Exchange 2013 for SharePoint 2013 Development Environment. Outbound email

Begin with setting up Exchange Server Receive Connector:
    • Open Exchange admin center (https://localhost/ecp) site;
    • Mail flow --> receive connectors:
    • Select Default Frontend Connector and edit it

    • In security section, make sure "Anonymous users" are allowed:

You can test outgoing email via PowerShell with the following script:
Add-PSSnapin Microsoft.sharePoint.powershell
$Dictionary = new-object System.collections.specialized.stringdictionary
$Dictionary.add("Subject","Testing email")
$Web = get-spweb "http://localhost"
$Body = "Sending it from PowerShell"

If this script returns #True - it worked just fine.
If it returned "#False" - you will need to check SharePoint ULS in order to find what happened exactly.

Possible problem with while testing outgoing email: 451 4.7.0 Temporary server error. Please try again later. PRX2":
Solution: make sure you've got only one DNS for your network adapter on your Exchange Server. Make sure you are using address of your DNS server of your local domain. Do not include any other external DNS servers.

Here are others things to consider:
  1. Make sure that IPv6 is enabled on Exchange server. This is important when you are trying to connect Outlook to Exchange Server:
  2. Add host file entries on your SharePoint server that target Exchange server you receive "could not resolve domain name" error:
(SharePoint Server's hosts file)

After all pain - success!