Thursday, 28 June 2012

Create custom master page in SharePoint 2007 using Visual Studio

  1. Open Visual Studio 2010 before that please install wspbuilder extension
  2. File->New->Project Select WSPBuilder Project under the WSPBuilder Category
  3. Add new item to the project Select Blank Feature with site scope in the WSPBuilder Category.
  4. Please add the folders and masterpage in the following strucure. 
  • Features
    • SugunthanMasterPageFeature(your feature folder)
      • _catalogs (folder)
        • masterpage(folder)
          • SugunthanMaster.Master(Your master page file)

      5. Remove the Code behind and designer cs files.
      6. Open the element files and change the code like following


<?xml version="1.0" encoding="utf-8" ?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <Module Name="SugunthanMasterPageFeature" Url="_catalogs/masterpage" Path="_catalogs/masterpage" RootWebOnly="TRUE">
    <File Url="SugunthanMaster.Master" Path="SugunthanMaster.Master" Type="GhostableInLibrary">
      <Property Name="ContentType" Value="$Resources:cmscore,contenttype_masterpage_name;"></Property>
      <Property Name="MasterPageDescription" Value="SugunthanMaster.Master" />
    </File>
  </Module>
</Elements>

Note Module Name is your Feature Name.

     7. Open the master page remove all coding
     8. Open any default master page in sharepoint designer and copy the code then paste to your master page
      9. Do the changes and add style what you need.
    10. Compile the code.
    11.  Add and deploy the solution
    12.  Open the Particular website and activate the feature in the site feature collection
    13.  Go to the settings in the look and feel change the master page as yours one.

Happy Coding:)

Wednesday, 20 June 2012

How to read the contact list of my exchange server mail account

This code read the contact list of my exchange 2007 server mail account using c#

private static void ListContacts(ExchangeService svc) {
    foreach (var v in svc.FindItems(WellKnownFolderName.Contacts,
                                    new ItemView(20))) {
        Contact contact = v as Contact;
        ContactGroup contactGroup = v as ContactGroup;

        //v.Load(); // Turns out you don't need to load for basic props.
        if (contact != null) {
            Console.WriteLine("Contact: {0} <{1}>",
                contact.DisplayName,
                contact.EmailAddresses[EmailAddressKey.EmailAddress1]);
        } else if (contactGroup != null) {
            Console.WriteLine("Contact Group: {0}", contactGroup.DisplayName);
            switch (svc.RequestedServerVersion) {
                case ExchangeVersion.Exchange2007_SP1:
                    ExpandGroupResults groupResults
                        = svc.ExpandGroup((contactGroup.Id));
                    foreach (var member in groupResults) {
                        Console.WriteLine("+ {0} <{1}>",
                            member.Name, member.Address);
                    }
                    break;
                case ExchangeVersion.Exchange2010:
                    foreach (GroupMember member in contactGroup.Members) {
                        Console.WriteLine("+ {0} <{1}>",
                        member.AddressInformation.Name,
                        member.AddressInformation.Address);
                    }
                    break;
                default:
                    Console.WriteLine(
                        "** Unknown Server Version: {0}",
                        svc.RequestedServerVersion);
                    break;
            }
        } else {
            Console.WriteLine("Unknown contact type: {0} - {1}",
                contact.GetType(), v.Subject);
        }
    }
}
 
Note:  Please install ews api and add the following references
using Microsoft.Exchange.WebServices.Data;
using System.Collections.ObjectModel;
 
Webservices available in the folder "C:\Program Files\Microsoft\Exchange\Web Services\1.2" 
before check this program .
 
Happy Coding :)