2013 in review

The WordPress.com stats helper monkeys prepared a 2013 annual report for this blog.

Here’s an excerpt:

The concert hall at the Sydney Opera House holds 2,700 people. This blog was viewed about 24,000 times in 2013. If it were a concert at Sydney Opera House, it would take about 9 sold-out performances for that many people to see it.

Click here to see the complete report.

SharePoint 2013 search API and parsing search results for data table (Part 2 of 3)

This is part 2 of a 3 part series which is about SharePoint 2013 search API and parsing search results using data table.

SharePoint developers – How can I forget about you while writing my blogs? This post is specifically for SharePoint developers who want to leverage SharePoint’s search API to get results from SharePoint search and convert them to data table and use them in their front-end screens.

Most of you, might already be aware that SharePoint 2013 is equipped with brand new REST based search API which resides at URL: http://sharepointportal/_api/search and you can get search result by passing this URL in browser: http://sharepointportal/_api/search/query?querytext=’muneeb’  –

However, in most of the cases we want to parse these results into data table and attach it with repeaters or data lists. There is no need to reinvent the wheel. I wrote a method which parses the data and converts your query results into data table which you can bind easily with user interface.

DataTable aTable = new DataTable();

private void ParseSearchResults(Uri uri){

HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(uri) as HttpWebRequest;

webRequest.Accept = “application/xml”;

webRequest.Credentials = System.Net.CredentialCache.DefaultNetworkCredentials;

HttpWebResponse response = (HttpWebResponse)webRequest.GetResponse();

 string result = string.Empty;

System.Xml.XmlDocument XMLDoc = new System.Xml.XmlDocument();

 using (StreamReader data = new StreamReader(response.GetResponseStream()))

result = data.ReadToEnd();

 XMLDoc.LoadXml(result); //Load XML in XML Document

 XmlNodeList nodeList;

XmlNode root = XMLDoc.DocumentElement;

nodeList = XMLDoc.GetElementsByTagName(“d:Table”); //Get Table Node.

 XmlNode TempNode = nodeList[0].ChildNodes[0].ChildNodes[0];

 // Adding columns in DataTable.

foreach (XmlNode childNode in TempNode.ChildNodes[0].ChildNodes)



 //Adding rows in DataTable.

foreach (XmlNode aNode in nodeList[0].ChildNodes[0].ChildNodes)


aRow = aTable.NewRow();

 foreach (XmlNode childNode in aNode.ChildNodes[0].ChildNodes)

aRow[childNode.ChildNodes[0].InnerText.ToString()] = childNode.ChildNodes[1].InnerText.ToString();



 //Accept changes to DataTable.



Call to the method:

ParseSearchResults(new Uri(“http://sharepointportalurl/_api/search/query?




I passed these parameters in query to make it more useful for me.

SourceID: I have configured many sources. A single source can point to SharePoint location that can be a document library or folder or even site collection (I will explain in my next post how to configure sources)

RowLimit: To limit the maximum number of results – Consider this where performance is an issue.

Selectproperties: Metadata which I want to return with my search results – otherwise, there are many additional fields which may not be required.

So its easy – just make your URL and pass to this method. It will give you a dataTable. J

Happy SharePointing !!



SharePoint 2013 custom field in not showing in crawled and managed properties

SharePointerssss. . . . ! ! !

Guys, I am back with another real life situation which left us all very frustrated and made us pull our hairs. Situation occurred with SharePoint 2013 search.

Problem statement: We had one column which was part of a content type in SharePoint 2013. After full crawling all other fields were showing up in SharePoint 2013 managed properties (now called search schemas) but ONLY this one field failed to appear.

Solution available over the internet is to reset crawl index and do full crawl again which we did atleast 6-7 times however, every time ONLY that one field failed to appear. Incremental crawls (set after 15 minutes) also failed to show any signs of this field.

After rigorous testing and findings we were finally able to solve it. Here I would specially thank my friend (Austin D Souza) for his patience and pointers. He is a great SharePoint Admin but above all a great human being. Thanks Austin.

Solution: For crawler to crawl a field and convert it into a managed property there should be at least one list item or one document with that data against that column. Unless data is not there that field won’t be crawled. I am not sure at this stage to call it a bug or a feature but it is there in SharePoint 2013. So if you are planning to add custom managed properties in SharePoint advance search pages then make sure you add some data against those fields to appear.

Note: Austin found that there are some memory leaks while doing SharePoint 2013 full crawl.

I hope it will help you all save a lot of trouble shooting time.

Many thanks!

Configuring SharePoint 2013 Search (Part 1 of 3)

Guys, I am here with another very interesting post drilling down SharePoint 2013 search capabilities and available features.  The following things will be discussed

  • Part 1: Configuring SharePoint 2013 “Result sources”
  • Part 2: SharePoint 2013 search API and parsing search results using data table
  • Part 3: Configuring SharePoint 2013 search center & redirect search queries to search center

Configuring SharePoint 2013 “Result sources”

As you guys, might already be aware that SharePoint search scopes are no longer available in SharePoint 2013. Scopes are replaced with more powerful “Result Sources”

Aaaahhhhh! “Powerful” in terms of “what” & “how”. . .

So let us see how “result sources” are more powerful and gives you more control. First of all result sources are available at site collection level which has now enabled site collection administrators to have better control over search. To configure some basic search settings now you are not required to login in central admin.

Having said that, it does not mean that you have crawling and search service application settings on site collection level. No not at all. Crawling and search service application (SSA) settings still reside in central admin and it still requires careful planning to configure it properly.

To add a new “result source” go to your site collection settings under “SEARCH” section (on left hand side) you will see “Result Sources” – Click it. Set protocol you want to follow (normally its Local SharePoint – in most cases) – As per Microsoft’s documentation.

  • Select Local SharePoint for results from the index of this Search Service.
  • Select OpenSearch 1.0/1.1 for results from a search engine that uses that protocol.
  • Select Exchange for results from an exchange source.
  • Select Remote SharePoint for results from the index of a search service hosted in another farm

What brings power to a “result source” is ultimate, brand new & out of the box “query builder” tool which is embedded in SharePoint search settings. This query builder will allow site collection administrator to transform incoming query, add keyword, set filters and configure source. For example if I want this ‘result source’ to return items which belong to particular site collection (titled: ‘tempSitecollection1’) then you will configure your result source using query builder like this:

{searchTerms} (path:”http://sharepointportal/sites/ tempSitecollection1/*” OR path:” https://sharepointportal/sites/ tempSitecollection1/*”) (contentclass:STS_List OR contentclass:STS_List_DocumentLibrary)

So this result source will contain records only from tempSiteCollection1 – Using this URL, you can scope this ‘result source’ to only one document library. Wasn’t that easy & powerful ;-) Using query builder you can also apply sorting and grouping clauses.

Powerful enough ;-)

Alhumduillah – I am awarded with “Najm” which means star

Najm Award

Apply for wife’s residence visa in UAE

Guys, I am here yet again with an interesting post with steps on ‘how to apply wife’s residence visa for UAE (Dependant VISA)’. First I will list the requriements which includes…

  • Computerized marriage certificate (NADRA’s) attested from MoFA of Pakistan then Consulate General of Pakistan in UAE and then MoFA of UAE
  • Your rental agreement on your name
  • DEWA bill (must be registered on your name)
  • Salary certificate in Arabic
  • Wife’s photo (Original Photo)
  • Copies of passport & VISA of husband
  • Copy of wife’s passport

Here is the step by step process…..

  1. Get computerized marriage certificate from NADRA
  2. Get your computerized marriage certificate attested from Ministory of Forign Affairs in Lahore
  3. After attestation from Ministory of Forign Affairs in Lahore is done ask your family to send you original computerized marriage certificate
  4. Once you have the original marriage certificate then get it attested from Pakistan Embassay in UAE. They will charge 8 AED (This takes only 30 minutes). Directly go to first floor. Go to Window 7 & 8. Deposit 8 Dirhams and they will guide you.
  5. Then go to Ministry of Foreign Affairs of UAE and then get it attested from there. They will charge 160 AED (This takes only couple of hours depending on the queue)
  6. Apply for new CNIC card of your wife in NADRA office Pakistan and apply for her passport as well (in Parallel).
  7. Get your rental agreement and get EJARI (EJARI is very important). Rental agreement must be on YOUR name.
  8. Get your latest DEWA bill. DEWA bill should also be on YOUR name.
  9. Get your salary certificate from your company in Arabic (Immigration will keep original one)
  10. Get copy of your passport & VISA and also copy of your wife’s VISA.
  11. Go to any typing center and pay 250 Dirhams and get the application typed in Arabic. They will give you a form. Cross check all details on the form. It should match with the details on the passport. This will take 10 minutes depending on the queue
  12. Once everything is complete then go to any immigration office and get your wife’s entry permit. Scan it and send it Pakistan so that she can travel.
  13. Once she is in UAE then apply for Medical. Once medical is done then apply for Emirates ID and in parallel apply for VISA stamping on passport. This will take about two weeks.

Get ‘OK to board’ from airline (where you are buying tickets) and submit original visa at the airport. They will charge you 50 Dirhams.

***** Very Important: Immigration guys need original documents so take all original documents along-with copy of your original passport & VISA with you ******

Good Luck!



Another appreciation from client – SharePoint Module

Got another appreciation from the client few days back.


Once again, many thanks for your assistance with the creation of this “site” .  It is working extremely well, and we’ve had really good feedback from the users.  This application has significantly reduced the time it would have taken to do this process via emails.

Kind regards

Make client side changes in SharePoint list’s NewForm.aspx or EditForm.aspx

Okay guys! Another very simple but very useful & interesting SharePoint post. I love when I come up with quick solutions.

Scenario: You create a list in SharePoint (of any type). When you click on New/Edit SharePoint opens new page. If you see URL you will see Lists/ListName/NewForm.aspx in case of if you pressed ‘NEW’ and Lists/ListName/EditForm.aspx in case if you edit an item.

Requirement: Client wants to add some kind of image on NewForm.aspx & EditForm.aspx and also wants to hide cancel button.

Quick solution that comes to mind: A very quick solution generally comes to our mind is to add some kind of javascript and on window load just add image from picture gallery or 14hive or any other location. Does that make sense? Yes, it does ;-)

Now in SharePoint: Na na na… You are in SharePoint and here you must know where to hit :-P so I will tell you how you will do it in SharePoint.

A clean way to do so is to add a content editor webpart on those pages and add whatever javascript you want to add. Isn’t it clean guys ;-) but question is how? So simple solution is in the URL of the page pass this as query string parameter: Toolpaneview=2 and you will see that your newform.aspx or editform.aspx page will open in edit mode (based on permissions of course) and here you can add a content editor webpart and hopefully we all know that we can write anything in content editor webpart. Isn’t it cool? Well it makes a lot of sense and is a clean solution as well.

Bottom line is use ToolPaneView=2 or ToolPaneView=3 as query string parameter to open newform.aspx or editform.aspx in edit mode (which is not available by default). This can be used to increase column width or hide cancel button or add an image on the page or change width of lookup fields (as far as you know how to write a perfect javascript) :-P

This way you can avoid creating a custom feature and also will avoid doing any builds on production server. I hope it will help you guys. Good luck! And Happy SharePointing.

Extend grace period of Microsoft Office 2013


Sometimes we need to extend the grace period of Microsoft products including Microsoft’s flagship product – Microsoft Office 2013. Here are the steps how to do it.

Run command prompt as Administrator

Go to location: %ProgramFiles%\Microsoft Office\Office 15

Type this command: cscript ospp.vbs /rearm

YES!!! You are done. Your office is activated again as you have extended your grace period. You can maximum do it for 5 times.

============ FOR OFFICE 2010 ============

Go to location: C:\program file (x86)\common files\microsoft shared\officesoftwareprotectionplatform and type ‘ospprearm’

Configure PDF iFilter for SharePoint 2010

I spent a lot of time trying to figure out the exact steps to properly configure PDF iFilters for content based search in SharePoint 2010. Here are the steps.

  1. Download and Install the Adobe PDF iFilter 9 from Abode’s site using ‘Run as Administrator’
  2. Download a 16X16 PDF icon file from the Adobe web site and copy it to C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\IMAGES\
  3. Add the following entry in the docIcon.xml file, which can be found at: C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\XML (This entry should be done under extensions tag) Entry is:     <Mapping Key=”pdf” Value=”pdf16.gif” />
  4. Go to your search service application in SharePoint’s central admin and ADD the pdf file type to the Search Service Application’s File types.
  5. Add a new registry entry in your Windows’ registry file at the following location:
  6. HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office Server\14.0\Search\Setup\ContentIndexCommon\Filters\Extension
  7. Right-click and select New > Key to create a new key called “.pdf” (without quotes)
  8. Add the following GUID as the default value for the .pdf key
  9. {E8978DA6-047F-4E3D-9C78-CDBE46041603}
  10. Open Windows Explorer and navigate to the following location:
  11. C:\Program Files\Adobe\Adobe PDF iFilter 9 for 64-bit platforms\bin
  12. Add your Search Service Application’s Content Access Account to the list of users and groups who have security access to this folder. Make sure the account has Read, Read & Execute, and List Folder Contents permissions (Very important)
  13. Reset your crawled index from search service configurations (Central admin)
  14. Reboot the SharePoint servers in your Farm to restart the Search Service Application.
  15. After reboot is done just re-crawl everything.

Hurraaaahhhhh! You are done! :)

MOSS Error – Operation is not valid due to the current state of the object

Hi Guys,

Today I am posting another very short but very interesting post which will save your hours of efforts and some hairs too.

Problem Statement: SPListItem.Update() and SPListItem.SystemUpdate() calls fails with the following error – ‘Operation is not valid due to the current state of the object’

One liner solution: Do NOT call SPListItem.Update() inside Evelvated Permission’s delegate

Detailed Solution: You must instantiate and populate SPSite and SPWeb object inside elevated Permission’s delegate but you should NOT call SPListItem.Update() or SystemUpdate() method inside your delegate control.

Here is the snippet of code which works (I wrote the following snippet in Microsoft Word – Please rectify if there are any complier errors)

SPListItem anItem = null;


using(SPSite aSite = new SPSite(“URL”))
using(SPWeb aWeb = aSite.OpenWeb())
SPList aList = aWeb.Lists[“ListName”];
anItem = aList.GetItemByID(1); //Or you can query your item.

anItem[“Field1”] = “ValueOfField1”;
anItem[“Field2”] = “ValueOfField2”;

I hope it will help you guys.

My Blogging year 2012 in review

The WordPress.com stats helper monkeys prepared a 2012 annual report for this blog.

Here’s an excerpt:

600 people reached the top of Mt. Everest in 2012. This blog got about 10,000 views in 2012. If every person who reached the top of Mt. Everest viewed this blog, it would have taken 17 years to get that many views.

Click here to see the complete report.

Extend evaluation period of Windows Server 2008 R2

Here I am for you guys with a small but very useful post. Many of us are using evaluation products from (Great, Awesome & Super) Microsoft including Windows Server 2008 R2. The evaluation period is normally for 60-90 days and once it gets expired and if you are still using it then you may face charges against illegal use of the product.

However, there is an option which is given by Microsoft through which you can extend your grace period by another 60 days.

  1. Click Start, and then click Command Prompt.
  2. Type slmgr.vbs -dli, and then press ENTER to check the current status of your evaluation period.
  3. To reset the evaluation period, type slmgr.vbs –rearm, and then press ENTER.
  4. Wait for a confirmation Window to show up.
  5. Restart the computer.

You can do it 3 times and get a total of 240 days :)

Thank you Microsoft.

The Web application at URL could not be found. Verify that you have typed the URL correctly. If the URL should be serving existing content, the system administrator may need to add a new request URL mapping to the intended application.

Here is another very important post based a problem which made me pull my hairs and after wasting 5 working days, I was able to find a solution.

When accessing SPSite object from a web application we get this error.

The Web application at URL could not be found. Verify that you have typed the URL correctly. If the URL should be serving existing content, the system administrator may need to add a new request URL mapping to the intended application.

Since, we cannot code in client object model (because of security issues) therefore, this was a blocking issue.

Piece of code which is creating problem:

SPSite aSite = newSPSite(“URL”);

 Steps to reproduce:

  1. Just create and empty web site project in VS 2010.
  2. Add SharePoint’s DLL reference.
  3. Add the above code page.
  4. Run the site

 Solutions which are available on internet:

  • Running the web application in 64-bit mode.
  • Changing to target framework to 3.0 instead of 4.0
  • Adding app pool identity user to WSS_ADMIN_WPG
  • Adding app pool identity user to Administrator group

 Error we get:

The Web application at URL could not be found. Verify that you have typed the URL correctly. If the URL should be serving existing content, the system administrator may need to add a new request URL mapping to the intended application.

One-liner solution summary: The app pool identity of the web-service and your SharePoint portal must be the same.

 Detailed solution: (in my case it was a web-service so I am posting my solution related to that)

  1. Create an empty folder on your favourite location using Windows file explorer
  2. Create an empty IIS website in IISManager (Run à inetmgr)
  3. While creating this new website in IIS it will ask for the physical path – Give it the same folder path which you created in step 1
  4. Click on test connection to make sure IIS has permission to this folder
  5. Next to Site name textbox there is Application Pool section. There is a ‘select’ button next to it – Just click it
  6. From this new dialog box select the application pool of your SharePoint site (This is MUST)
  7. Click OK and then change the port to any available port
  8. Run your development environment (in my case Visual Studio 2010) as administrator
  9. Go to your web-service project –> Right click and publish –> Select file system –> From target location’s text box click browse –> Select local IIS and select your website.
  10. Select radio button ‘Delete all existing files prior to publish
  11. Click Open à then click publish
  12. Open browser and go to localhost:portnumber (portnumber you gave in step 7)

 To debug: In order to debug your code in this published web-service attach it to all w3wp (worker process) instances J

I hope it will help you all save your precious time and hairs on the head :D

Happy SharePointing ;-)

How to get protector certificate against employment visa in Pakistan

Today, I will explain how to get protector document (a MUST document for all employment VISAs by Immigration of Pakistan). Without protector (in case if you have employment VISA) you will not be allowed to leave Pakistan and will be returned from the airport.
  1. Get passport sized pictures with white background (at-least 20 – rest will be consumed in UAE).
  2. Getting the degrees verified from (in order) HEC, Foreign Office and UAE Embassy (please follow my blog post https://ahmedmuneeb1.wordpress.com/2012/09/11/steps-to-apply-for-employment-visa-for-any-gulf-based-country/
  3. Once the employment VISA is processed then there is a requirement from Immigration office Pakistan to get a ‘protector certificate’ which usually takes one day and can be done from their Lahore or Rawalpindi office – Lahore office’s address is 117-G Model town, Lahore. Fee is PKR 6500/- and following are the pre-requisites
  • NICOP (National Identity card for overseas Pakistanis) or if you don’t have it then apply for it at NADRA office (this will take one extra day) they will issue you a slip and a number which can be submitted instead of card itself.
  • 2 copies of Passport + 1 copy of employment contract + 1 copy of NICOP or NADRA’s NICOP application slip (in case if you don’t have NICOP card) + 1 copy of NADRA card (National Identity card) and couple of picture with white background.
  • Go to 117-G Model town, Lahore at 9AM sharp (it will be a long queue). Must take your original documents with you (Passport, CNIC, NICOP). Submit documents along with fee before 12 Noon and they will give you the certificate by 3PM. 

Must keep your original documents with you (Especially Passport and NIC) all the time.

Please note that if the candidate does NOT have a protector certificate he wont be allowed to travel by the immigration of Pakistan and will be returned from the air port.

There is no concept of ENCR stamps for Pakistani Passports- It only applies to Indian Passports.
Ok to board – Self explanatory :-)

Very important: Please get the employment contract and VISA from your employer at-least 4 days before the date of flight so that you can get ’protector document’ easily.
Without VISA and employment contract this ‘protector document’ is NOT issued and without protector you won’t be able to travel.
Please DON’T do any processing on 11th hour in Pakistan even if you are 100% sure :-|

Make a factorial calculator in C# without multiplication sign

Guys, today I came up with another very interesting post. Though this is a class assignment for an intermediate level students but most of developers ran into this problem and don’t find a way out. So here is a simple post for them with source code and guidance.

A factorial calculator will do some basic maths like this: 5! = 5x4x3x2x1 = 120

However, basic problem is we are NOT suppose to use the multiplication sign while calculating the factorial results. So here is the code. Remember! This is a console application – Make a new console app and add the following code in your console app.

Download factorial Calculator in C# without using multiplication sign source code here

  static void Main(string[] args)
                Console.WriteLine("Enter the digit to find factorial");
                int FactorialDigit = int.Parse(Console.ReadLine());

                List<int> ListOfFactorialResults = new List<int>();
                ListOfFactorialResults.Add(Multiplication(FactorialDigit, --FactorialDigit));

                int i = 1;
                while (FactorialDigit -1 > 1)
                    ListOfFactorialResults.Add(Multiplication(ListOfFactorialResults[i-1], --FactorialDigit));

                Console.WriteLine(string.Format("Factorial of this number is : " + "{0}",
                        ListOfFactorialResults[ListOfFactorialResults.Count -1]));
            catch (Exception ex)

        public static int Multiplication(int FirstDigit, int SecondDigit)
                int i = 0, product = 0;

                while (i < FirstDigit)
                    product = product + SecondDigit;
                return product;
            catch (Exception ex)
                throw ex;

I hope it will help students and some developers too ;-)


Steps to apply for employment VISA for any GULF based country (UAE VISA)

Guys, I hope you are doing great. I am about to write a very important post on ‘steps to apply for employment VISA’ for any GULF based country. I hope this post will help you avoid all the KHAWARI that I have been through.

Please note: These steps are according to the procedures in place till Sep, 2012. However, all procedures are subject to changes so please coordinate with concerned departments before starting your process.

VERY VERY IMPORTANT: First of all open your Matric/O’Levels degree, Intermediate/A’Levels degree, Graduation degree, CNIC and Passport to make sure that YOUR NAME and your FATHER’s NAME is exactly the same at all places including cast. (Example: Khurram Butt s/o Haji Gulam Sarwar Butt –> All your degree must contain Haji & Butt). Embassy these days are not validating any degrees which are NOT fulfilling this requirement. Otherwise, you have to make a new CNIC and then Passport or get them rectified on your degrees.


  • Get your latest passport size pics in red, blue and white backgrounds
  • Get at least 3 copies of all your academic degrees, Passport and CNIC.
  • Keep your original Passport, CNIC and degrees with you wherever you go.
  • After you get documents attested from HEC get new photocopies (front/back side both)
  • After you get documents attested from foreign office get new photocopies again (front/back both)
  • HEC’s stamp is only valid for 6 months. Renew it first if its older at your degree. HEC renews it for FREE!

Step No. 1: Getting Degrees verified (A real pain in the ass) :@
You have to get your degrees verified from three institutions – I will guide you how to avoid all the pain and save your money & precious time.

  1. HEC (Higher education commission)
  2. MoFA (Ministry of Foreign Affairs)
  3. Embassy of any GULF country

Getting Degrees verified from HEC:

  1. Go to HEC’s site and verify that your university was in the list of recognized universities. Here is the link: http://www.hec.gov.pk/OurInstitutes/Pages/Default.aspx
  2. Read the guidelines given by HEC on their site for degree attestation: http://www.hec.gov.pk/InsideHEC/Divisions/QALI/DegreeAttestationEquivalence/DegreeAttestationServices/Pages/welcome.aspx
  3. Apply online and reserve your time slot. HEC will give you a time slot (Example 5 days). They will tell you date & time and you have to be there in their office at allocated date & time. Go to this link to apply online: http://das.hec.gov.pk/
  4. Now this step is your prerogative how you want to proceed there are two options
    1. Option A: After applying online go to nearby OCS shop and give your degrees/transcript to them along with fee which is Rs. 800 per degree and Rs. 500 per photocopy (These are HEC charges) and Rs. 220 (OCS charges). They will get it done for you in 9-11 working days.
    2. Option B: After applying online go to HEC’s office yourself in Islamabad at allocated date & time and get it done yourself. This will consume your whole day as you have to be there at HEC’s office by 9AM.
    3. Now you are done with HEC’s verification

Getting Degrees verified from Ministry of Foreign Affaris (MoFA):

  1. Prerequisite is that you must first get your degrees verified by HEC. This step is very important. Do NOT get your time wasted by directly going to MoFA. First get the Step 1 above done.
  2. This step is easy and multiple options
    1. Option A: If you are based in Lahore and your degrees are also from Lahore then go to 82-Gulberg 2. This is foreign office’s camp office. They collect degrees before 12 Noon and will return back to you by 4PM after attestation. This will take only 4-5 hours. For a degree & transcript they will charge Rs. 50  If you have your own vehicle then here are driving direction
      1. Go to canal road and start moving towards Jail road (Coming from thokar towards mall road)
      2. Just BEFORE the underpass of Jail road there is left-turn (Do NOT go to the underpass of Jail road or to the jail road) there you will find 82-Gulberg 2. It is camp office of MoFA in Lahore.
    2. Option B: If you are Islamabad based or can go to Islamabad then get it done yourself. Foreign offices usually have long queues so to avoid them be there at 7AM and reserve your token. The sooner you go the better it will be. They serve you on first come first serve basis. This will also take one day. For a degree & transcript they will charge Rs. 50
    3. Option C: If you do NOT want to go to MoFA office by yourself just to OCS office/UPS office they will charge you some amount and get it done for you. This process will take around 7 working days. No urgent service is available in this case.

Getting your degrees verified by embassy:

Entering the diplomatic enclave in Islamabad is hell of a job. If you know anyone inside ask him for the favor to get your documents verified. Otherwise the best option is to SASHA’s office which is based in Islamabad give them USD 60 (urgent processing fee). This will take 1-2 days and without any pain you can get it done but you have to go to Islamabad yourself to visit SASHA’s office. SASHA deals with all embassies of all GULF countries. Important thing: If you pay them in USD then it’s fine otherwise they will charge you extra on top of dollar exchange rate. Here are their details. . .

SASHA International
2nd Floor Flat # 8, Block No. 16
LIBRA Market (Khadda Market)
Near PSO Pump – MARKAZ G-7, Islamabad
Tel: +92-51-2204469, 051-2204686 – Email: sasha.668@hotmail.com
Google map coordinates: (33.70261743200274, 73.07481050491333)

Step No. 2: Getting the medical examination
If you are in Lahore, Pakistan then go to Chugtai labs, Jail road (Do NOT go to any collection center – They will take full one day) and give fresh blood samples for the following tests

  1. Complete blood picture will cost Rs. 500
  2. Hepatitis (All types) will cost Rs. 1800
  3. X-RAY of lungs for symptoms of TB/smoking
  4. Any other (if advised by employer/consulate)

Chugtai labs will publish your test reports online within 3-4 hours and will send you SMS alert. You can get it printed online using your Patient & Case IDs. I hope this will help you. Please keep me posted with your comments/suggestion or any information you know.


Show a picture to user before uploading it

Hey Guys,
I am here with a very interesting post… We ran into a very exciting requirement by the client to show the picture in the picture box before uploading it to the server. So here is the code to do it.

Add this code on your HTML Page…

Since, the File upload control is of ASP.NET so you can easily call it access it in your code behind files. I hope, this post will help you all. You can post your comments/questions here… :-)

Boot using Microsoft Windows 7 VHD

Guys, finally I am back with another interesting post on a topic which is very near and dear to my heart. Yes, I am talking about “Virtualization”…. I have been reading a lot of blogs about this topic and I must say that Microsoft has done a huge job in getting it out of its door. With the release of Windows Server 2008 R2, Hyper-V has shown a lot of improvements. This post does not cover the improvements of Hyper-V and features of Virtualization in Microsoft Windows 7 and Microsoft Windows Server 2008.

Objective of this post is to highlight the process through which you can boot using a pre-built Windows 7 VHD file and make it work like a real environment which means you can boot from this VHD file and it will utilize the full capacity of your machine (Full processor, Full RAM and all hardware). In short a virtual machine (VHD) will be used as a complete OS (dual boot)


  1. You have a VHD file with Windows 7 or Windows Server 2008 installed on it.
  2. You have enough space in the hard disk as per the size of the VHD. If VHD is 127GB, you must have 127GB available space in your hard drive.
  3. Preferably SSD with good read/write speed as IO will be compromised a lot here. Although this is not required but if you have it then its good otherwise, you will experience decline in the performance.


I have Windows Server 2008 R2 installed on my machine and I have Windows 7 installed in my virtual environment so I have a VHD file with Windows 7 installed in it and I want to have a dual boot menu which will show up two options.

  1. Microsoft Windows Server 2008 R2 <– This will boot from the real environment
  2. Microsoft Windows 7 <– This will boot from the VHD file


  1. Boot your Windows Sever 2008 R2
  2. Run your VHD file using Hyper-V manger
  3. Once the virtual environment is booted you can press CTRL + ALT + BREAK to view in full screen.
  4. In your virtual OS (in my case it is Windows 7). Go to command prompt.
  5. Go to c:\Windows\System32\sysprep
  6. Type sysprep /shutdown /generalize
  7. This will open a dialogue box.
    1. Check the generalize check box
    2. In System clean-up action: Select Enter System Out of box Experience
    3. In Shutdown option, select shutdown.
    4. Click OK
  8. Wait for this operation to complete. See some details about SysPrep at the end of this blog.
  9. Once the process is complete, it will shutdown the virtual machine. DO NOT run the virtual machine again.
  10. It’s time to update the boot menu options. For this process, use a utility BCD which comes with Windows. However, you can download any wrapper utility with an easy user interface to do it. In my case, I download easyBCD. Download it, install it and run it.
  11. Add one boot option using easyBCD. Refer to the 3rd snapshot.
  12. Reboot your machine and you will see a boot menu with two entries. In my case, they are
    1. Microsoft Windows Server 2008 R2
    2. Microsoft Windows 7
  13. Select Microsoft Windows 7 (which was on my VHD) and let it boot. Once booted it will install new drivers and will open up Windows setup again. The setup will guide through the process. NOTE: You are NOT required to re-install windows. It is just the reconfiguration which Windows will take care of.
  14. Once the process is done it will reboot. Now you are good to go. Reboot Windows 7 and check the process and RAM – You will be surprised…






More Information about sysprep:
Desktop deployment is typically performed via disk cloning applications. Sysprep can be used to prepare an operating system for disk cloning and restoration via a disk image. Windows operating system installations include many unique elements per installation that need to be “generalized” before capturing and deploying a disk image to multiple computers. Some of these elements include:

  • Computer name
  • Security Identifier (SID)
  • Driver Cache

Sysprep seeks to solve these issues by allowing for the generation of new computer names, unique SIDs, and custom driver cache databases during the Sysprep process.

GOOD JOB Microsoft :-)

Another SharePoint WorkFlow project for Gulf client…

Hi All,

So Im back! with another exciting round of blogs for you people… However, I would first like to let you know about our up-coming project. It’s for Gulf based client – A leave approval workflow to be designed from strach on top of ASP.NET 3.5 and SharePoint 2010. See some of the images below… Smile

Another recommendation from the freelance client

From one of my very prestigious freelance client – March 25, 2010

Muneeb is that one in a million rockstar developer you’ve always been looking for but never can seem to find. The real deal. My experience so far in working with his team has been superb. They are always proactive and right on or above schedule. When he sets a goal – he meets it. When he makes a promise – he keeps it. I’m glad we’ve connected and looking forward to many successful endeavors in the years to come.

An exception of type Microsoft.SharePoint.Upgrade.SPUpgradeException was thrown during SharePoint Configuration wizard at step-2

Like many others, I have SharePoint 2007 installed on my Windows Server 2003 with SP2 box for custom development tasks; however, I also have Office 2010 Beta 2 installed on my machine of which has caused me a problem when attempting to run psconfig after installing the October 2009 CU patches (instructions to get these updates can be found from the SharePoint blog post here -> http://blogs.msdn.com/sharepoint/archive/2009/10/29/october-2009-cumulative-update-packages-for-sharepoint-server-2007-and-windows-sharepoint-services-3-0.aspx).

The Configuration Wizard will immediately throw the following exception after entering step 2:

PS C:> psconfig -cmd upgrade 
Copyright (C) Microsoft Corporation 2005. All rights reserved.ion 12.0.6500.5000

Performing configuration task 1 of 4 
Initializing SharePoint Products and Technologies upgrade…

Successfully initialized SharePoint Products and Technologies upgrade.

Performing configuration task 2 of 4 
Initiating the upgrade sequence…

Failed to initiate the upgrade sequence.

An exception of type Microsoft.SharePoint.Upgrade.SPUpgradeException was thrown.  Additional exception information: One or more types failed to load. Please refer to the upgrade log for more details.

Total number of configuration settings run: 2 
Total number of successful configuration settings: 1 
Total number of unsuccessful configuration settings: 2 
Successfully stopped the configuration of SharePoint Products and Technologies. 
Configuration of SharePoint Products and Technologies failed.  Configuration must be performed before you use SharePoint Products and Technologies.  For further details, see the diagnostic log located at C:Program FilesCommon FilesMicrosoft SharedWeb Server Extensions12LOGSPSCDiagnostics_11_1_2009_23_12_41_346_95884360.log and the application event log.

If you look into the Upgrade.log file you will see the following associated exception text:

[SPDelegateManager] [DEBUG] [11/1/2009 11:12:42 PM]: Begin registering Microsoft.Office.InfoPath.Server, Version=, Culture=neutral, PublicKeyToken=71e9bce111e9429c. 
[SPDelegateManager] [DEBUG] [11/1/2009 11:12:42 PM]: No assembly manifest found. 
[SPDelegateManager] [ERROR] [11/1/2009 11:12:42 PM]: Failed to call GetTypes() 
[SPDelegateManager] [ERROR] [11/1/2009 11:12:42 PM]: Method ‘get_ServerInfo’ in type ‘Microsoft.Office.InfoPath.Server.DocumentLifetime.XmlFormHost’ from assembly ‘Microsoft.Office.InfoPath.Server, Version=, Culture=neutral, PublicKeyToken=71e9bce111e9429c’ does not have an implementation. 
[SPDelegateManager] [ERROR] [11/1/2009 11:12:42 PM]: Failed to call GetTypes() 
[SPDelegateManager] [ERROR] [11/1/2009 11:12:42 PM]: Method ‘IsCurrentUser’ in type ‘Microsoft.Office.InfoPath.Server.SolutionLifetime.UserHost’ from assembly ‘Microsoft.Office.InfoPath.Server, Version=, Culture=neutral, PublicKeyToken=71e9bce111e9429c’ does not have an implementation. 
[SPDelegateManager] [ERROR] [11/1/2009 11:12:42 PM]: Failed to call GetTypes() 
[SPDelegateManager] [ERROR] [11/1/2009 11:12:42 PM]: Method ‘get_ServerInfo’ in type ‘Microsoft.Office.InfoPath.Server.SolutionLifetime.XmlFormProxy’ from assembly ‘Microsoft.Office.InfoPath.Server, Version=, Culture=neutral, PublicKeyToken=71e9bce111e9429c’ does not have an implementation. 
[SPManager] [ERROR] [11/1/2009 11:12:42 PM]: CanUpgrade [SPConfigurationDatabase Name=SharePoint_Config Parent=SPDatabaseServiceInstance Name=sql2008] failed. 
[SPManager] [ERROR] [11/1/2009 11:12:42 PM]: One or more types failed to load. Please refer to the upgrade log for more details. 
[SPManager] [ERROR] [11/1/2009 11:12:42 PM]: at Microsoft.SharePoint.Upgrade.SPDelegateManager.RegisterAssembly(Assembly asm, UInt32 nOrder) 
at Microsoft.SharePoint.Upgrade.SPDelegateManager.get_InitialTypeDictionary() 
at Microsoft.SharePoint.Upgrade.SPDelegateManager.GetDelegateTypes(Type tpObject) 
at Microsoft.SharePoint.Upgrade.SPDelegateManager.GetDelegates(Object o) 
at Microsoft.SharePoint.Upgrade.SPDelegateManager.GetUpgraders(Object o) 
at Microsoft.SharePoint.Upgrade.SPManager.CanUpgrade(Object o)

WORK-AROUND: The issue appears to be associated to having the new Office 2010 beta products installed and specifically InfoPath 2010. I am investigating the assembly conflict but the easiest work-around for now is to simply uninstall InfoPath 2010 (beta) and re-run psconfig again (you should not need to uninstall any other 2010 beta product and this will likely be a non-issue at RTM).

Another Live InfoPath Project

"The beast is finally tamed" – Ohhh! I still remember this sentence. This was once said by my PM (Athar Shafiq – Xavor) when we completed the Portal migration project (SPS 2003 to MOSS 2007) for Broadcom, US. The relevance of this sentence is very much the same today as I have completed yet another huge & difficult project in MOSS 2007 which was based on InfoPath Form Services having worth 900 USD and was scheduled to complete in one month’s time and By the Grace and Blessing of Allah I was able to do fully deliver it as per the schedule and below is the feedback from the client who gave me 5.0 rating out of 5.0 J

"This gentleman had excellent skills sets has it has to do with programming SharePoint Infopath and web services. This gentlemen was paid in other methods for a very complex InfoPath project. What I found most important in a good programmer is that he has tenacity to get the job done. He worked with me feverishly while there was a 6.0 earthquake in his country. My hat is off to this Muneeb for his programming skill set and his tenacity to get the job done."

Project Details:
The project was for doctors who wanted their patient examination form to be electronically submitted to their fully developed portal which is based on MOSS 2007. Therefore, the best option was to use InfoPath form services. Furthermore, some requirements logically came to one outcome to publish the form as content type and to make the form web browser enabled. In a nut shell, the form was browser enabled and must be published as a new content type in MOSS.

Limits and Limitations: When I was in Abu-Dhabi, someone told me that, "When we talk about limits, we also talk about limitations". Same was the case with this project; since the scope of the project was limited therefore there were few limitations as well which were introduced by the InfoPath, which were as follows.

  • Required to export the form in simple text file.
  • Client required tabs in InfoPath forms which InfoPath don’t have.
  • Since the form was browser enabled & published as CT, therefore, NO code was allowed inside the form.
  • There were few rules inside the form which required permission handling. Example: Hiding the form from all other except authors on certain conditions.

To overcome this scenario, I had to bind an event handler with the form library which makes some decision based on data inside the form and export data its data. Furthermore, on specific form statuses, permission and rules of the form gets changed, therefore, the project had three sections (InfoPath Form itself, One custom web-service, Event Handler).

As we know, that usergroup.asmx web-service’s schema needs to modify so that it can return proper values when used with InfoPath forms, so to avoid this customizations everything I change its reference, I wrote custom web-service to use usergroup.asmx web-service and this custom WS was called from InfoPath form.

Now something about form tabs. As we know that inside InfoPath there is no such control, therefore, I have to make something which looks like tab control therefore, I manage it with Buttons, Sections, Rules and hidden control fields. This was a very difficult part of the project.

Finally about event handler: I used event handler primarily for two purposes

  1. To modify permissions after item is added (which is based on form status which is present inside the form).
  2. To export form’s data in a simple text file which must be available to users for download.
Since, the event handler acts after item is added to the form library, therefore, all fields of the form can be read when you treat this form as an item (rather XML file). So I used System.IO to read the contents of the XML file (InfoPath Form) therefore, to export form data we can read all its fields and put them in a text file which is then attached to an item of another support list (a custom list with attachment field).
Here are few snapshots!

Making custom breadcrumbs for Document library

Hi Folks,
Today, I am writing this blog to give some pointers on developing custom breadcrumb control for document library… So here it is…

Actually the problem with SharePoint’s document library is when it is displayed using list view webpart and you move in a child folder of document library then there is no way you can find “Where are you?” It seems like you have lost your way… Now consider this scenario that you have to move in 12 child folders and want to come back to 6th folder you came from, and then it would be simple hell… But don’t worry I am here with a simple web-part which will help you out to overcome this problem.

So the first thing that you should do is to start with creating a simple web-part.

Technique: The simple way is to do the URL parsing and add hyperlinks separted by “>” sign.

I have uploaded the DLL file on the following URL: http://cid-b2ab571dd1ccb4f0.skydrive.live.com/self.aspx/.Public/CustomBreadCrumb.dll

Dont forget to make the following entry in web.config file’s (located at: C:InetpubwwwrootwssVirtualDirectories80) safe controls tags

<SafeControl Assembly=CustomBreadCrumb, Version=, Culture=neutral, PublicKeyToken=9f4da00116c38ec5 Namespace=CustomBreadCrumbTypeName=* Safe=True />

I hope this DLL file will be very useful for you people. Waiting for your feedback for further improvements.

Bulk Check-in inside a Document library

Hi Folks, I am back with yet another very interesting post regarding bulk check-in from a document library.

First the requirements:
  1. The initial requirement from the client was that, it wants to do bulk check-in inside a document library.
  2. Users must be able to see a link in “Actions” menu of a document library which navigates to a new page from where users must select the file(s) to check-in and they gets checked in with some certain comments.
Now the analysis:
User requirments clearly showed two things.
  1. Customization of “Actions Menu” of a document library.
  2. As there can be multiple document libraries so we need to figure out a way through which we can put it in all document libraries.
  3. Development of a custom page from where users can select multiple documents and check them in the document library.
Let me show you couple of snapshots here so that you guys can have a better idea of what we are gonna build in this blog in next couple of minutes.
Now the steps in the development:
First create a feature to customize “Actions Menu”. There will be two CAML files including (Feature.xml and actions.xml). As you might be familiar that feature.xml file defines the features basis including the scope, description, title etc of the feature itself. However, actions.xml file will define the customization of the menu. Please note that you can also customize the context menu here as well.
This post is still continued and will get completed till tomorrow…. Please wait… Thanks

Zip contents of a document library…

Hi Folks,

So here I am with another very interesting post which is about zipping the contents of a document library and saving them on a network or local location. Actually I am currently working on a huge MOSS based project for Trubiquity, it a huge application with very large number of employees. The basic objective of the application is to facilitate the clients (with multiple teams)  to manage their projects on a central location with all project management functionality, so SharePoint (MOSS) platform was chosen for it and rightly so, because of the fact that we need project management template with some out of the box feature including KPI, dashboards and many more….

Now the scanerio: There was a client request that whenever, he closes a project, he wants to zip the contents of the document library (in future, it may expand to any library) to any downloadable location. So I used SharePoint’s OM (object model) to achieve the functionality as this piece of code will eventually get wrapped inside a web-service so that it can be called from a remote location as well.

First the pre-Req: As the requirement is to zip all files and as document library can consist of multiple folder hierarchies, so first we need to create the same folder structure on any location (may be remote as well) from where  I will zip it. So I have used some J# classes as well to zip the folders.

Now the Solution with code and explanation: So here it is, the solution and code.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

using Microsoft.SharePoint;

using System.Collections;
using System.IO;
using java.util.zip;

namespace CloseSiteFeature
    public partial class frmMain : Form
        SPSite aSite = new SPSite("http://vm-winserver&quot;);
        Hashtable ListsTable = new Hashtable(); // to bind a combo box with a datasource which will be a hashtable in this case.
        bool IsLoaded = false;

        string SavePath = @"\mac-ali3My Shared";
        string RootPath = string.Empty;

        BindingSource bs = new BindingSource();
        SPWeb aWeb;

        public frmMain()

        private void frmMain_Load(object sender, EventArgs e)
            aWeb = aSite.OpenWeb();

            foreach (SPList aList in aWeb.Lists)
                if (aList.Hidden == false && aList.Title.ToString() != "Form Templates")
                    if (aList.BaseType.ToString() == "DocumentLibrary" && aList.BaseTemplate.ToString() == "DocumentLibrary")
                        ListsTable.Add(aList.Title.ToString(), aList.RootFolder.ServerRelativeUrl.ToString());

            bs.DataSource = ListsTable;

            cmbDocLibs.DataSource = bs;
            cmbDocLibs.DisplayMember = "Key";
            cmbDocLibs.ValueMember = "Value";

            IsLoaded = true;


        System.IO.DirectoryInfo DirInfo = null;
        SPFolder aFolder;

        private void cmbDocLibs_SelectedIndexChanged(object sender, EventArgs e)
            if (IsLoaded)
                    aFolder = aWeb.Folders[cmbDocLibs.SelectedValue.ToString()];
                    Directory.CreateDirectory(SavePath + aFolder.Name.ToString());
                    DirInfo = new DirectoryInfo(SavePath + aFolder.Name.ToString());
                    RootPath = SavePath + "\" + aFolder.Name.ToString();
                    GetSPFolderContents(aFolder, RootPath);

                    java.io.FileOutputStream fos = new java.io.FileOutputStream(@SavePath + aFolder.Name.ToString() +".zip");
                    java.util.zip.ZipOutputStream zos = new java.util.zip.ZipOutputStream(fos);
                    System.IO.DirectoryInfo di = new System.IO.DirectoryInfo(@SavePath + aFolder.Name.ToString() + "\");
                    ZipDirectory(fos, zos, di, @SavePath + aFolder.Name.ToString() +"\");

                    MessageBox.Show("Successfully done!");

                catch (Exception ex)
                    DirInfo = new DirectoryInfo(SavePath + aFolder.Name.ToString());

        private void ZipDirectory(java.io.FileOutputStream fos, java.util.zip.ZipOutputStream zos,System.IO.DirectoryInfo di,String SRootDir)
            java.io.FileInputStream fis;
            java.util.zip.ZipEntry ze;
            //to get file info from the directory
            System.IO.FileInfo[] fInfos = di.GetFiles();
            foreach(System.IO.FileInfo fInfo in fInfos)
                //Debug.Write(string.Format("Zipping {0}rn", fInfo.FullName));
                //give the zip entry or the folder arrangement for the file
                ze = new java.util.zip.ZipEntry(fInfo.FullName.Substring(SRootDir.LastIndexOf("\") + 1));
                //The DEFLATED method is the one of the methods to zip a file
                //Input stream for the file to zip
                fis = new java.io.FileInputStream(fInfo.FullName);
                //Copy stream is a simple method to read a file input stream (file to zip) and write it to a file output stream(new zip file)
                CopyStream(fis, zos);
            //If the directory contains the sub directory the call the same procedure
            System.IO.DirectoryInfo[] dinfos = di.GetDirectories();
            foreach (System.IO.DirectoryInfo dinfo in dinfos)
                //Debug.Write(string.Format("Zipping directory {0}rn", dinfo.FullName));
                ZipEntry dirEntry = new ZipEntry(dinfo.FullName.Substring(SRootDir.LastIndexOf("\") + 1) + Path.DirectorySeparatorChar);
                ZipDirectory(fos, zos, dinfo, SRootDir);

        void CopyStream(java.io.FileInputStream src, java.util.zip.ZipOutputStream dest)
            java.io.InputStreamReader reader = new java.io.InputStreamReader(src);
            java.io.OutputStreamWriter writer = new java.io.OutputStreamWriter(dest);

            while (reader.ready())


        private void GetSPFolderContents(SPFolder Folder, string path)
            byte[] binFile;

            foreach (SPFile aFile in Folder.Files)
                binFile = aFile.OpenBinary();
                if (binFile.Length >= 0)
                    FileStream fs = new FileStream(path + "\" + aFile.Name.ToString(), FileMode.OpenOrCreate, FileAccess.Write);
                    fs.Write(binFile, 0, binFile.Length);

            if (Folder.SubFolders.Count > 0)
                foreach (SPFolder subFolder in Folder.SubFolders)
                    if (subFolder.Name != "Forms" && subFolder.ParentFolder.Name.ToString() == path.ToString().Substring(path.LastIndexOf("\") + 1))
                        DirInfo = new DirectoryInfo(path);
                        RootPath = path;
                        GetSPFolderContents(subFolder, path + "\" + subFolder.Name.ToString());
                path = RootPath;

Happy SharePointing and please keep me posted so that I can make any further changes/enhancement if required. Thanks


Reading emails & email headers from Outlook mail using C# – Part II

Hi Guys! This is continuation of my previous entry on reading emails and email header from Outlook PST file using C#. If you somehow, missed the first part you can have a look at it here

So in my previous part, I showed you how you can read header of an email from a PST file by specifying a particular header name (e.g. CC List, TO list, Subject, From etc), however, our requirement was to make the email message RFC 822 compliant but when you try to read header of an email item you wont be able to find all header in email item object, so here’s is the only way that you can read all headers in just one GO… Smile

string SchemaTransportHeader = @"http://schemas.microsoft.com/mapi/proptag/0x007D001E";

These two lines will provide you all headers of a particular item. Hopefully this will help you all in reading emails from Outlook (PST) file and making them RFC 822 compliant.

Happy coding dudes! Thanks

Reading emails & email headers from Outlook mail using C# – Part I

First, some news about myself, I left PiSigma Group, Islamabad and now working with DigiDent solutions Pvt. Ltd as Sr. Consultant. It’s a very good place to work in with lots of growth opportunities. At-least, hopefully, I will get paid on time here Smile

Now something about my latest work in this company. It was my first week and I was asked to do a task of reading all emails from a PST file (OUTLOOK 2007) and show all header information with subject, attachments and body of the message in a console application. Eventual goal, is to migrate all emails to GOOGLE. Interesting… hun?

Now first the scenario:

  1. Read all emails from PST a file. PST file can be the default PST or the user can specify his own PST file from a custom location.
  2. Read all headers of the email.
  3. Read message body & subject.
  4. Show attachments of the email.
  5. Show ‘TO’ and CC’d lists.


Reading emails and some headers is now very easy using VS 08 and referencing few Microsoft Office 2007 DLLs which are already present in "Add Reference" section of visual studio. So Microsoft helped us remove those worries and saved us from DLL hell and COM components. Please add reference of Microsoft.Office.Interop.Outlook version 12 in your application and use the API for further work.

using OutLook = Microsoft.Office.Interop.Outlook;

However, the problem arise when you need to read all header in just one go (based on RFC 822 email message standards), without specifying any specific headers. I hope, I am able to clearly mention the point of concern here. Moving further here is the piece of code which will help you read Outlook emails.

static OutLook.Application app = new OutLook.Application();

static OutLook.NameSpace outlookNs = app.GetNamespace("MAPI");

static OutLook.MAPIFolder rootFolder = outlookNs.GetDefaultFolder(Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderInbox);


foreach (OutLook.MAPIFolder SubFolder in rootFolder.Folders)


if (SubFolder.DefaultItemType.ToString() == "olMailItem") //This will check for Mail folders only


if (SubFolder.Name != "Deleted Items")



GetSubFoldersAndItems(SubFolder, tvMailFolders.Nodes[i]);






This code will read all emails from a default store (default PST file). However, if you would like to read emails from a custom location you need to add that PST as store in your Outlook application and then iterate. Here’s is that piece of code as well. Furthermore, this code will show all Folders as "TreeNodes" and all emails and "Sub-nodes" by calling a re-cursive function (which is also given below).

outlookNs.AddStore(txtPSTFileLocation.Text); //txtPSTFileLocation is the textbox name.

OutLook.MAPIFolder rootFolder = null;


for (int j = 1; j <= outlookNs.Stores.Count; j++)


if (outlookNs.Stores[j].FilePath.ToString() == txtPSTFileLocation.Text)

rootFolder = outlookNs.Stores[j].GetRootFolder();



foreach (OutLook.MAPIFolder SubFolder in rootFolder.Folders)


if (SubFolder.DefaultItemType.ToString() == "olMailItem") //This will check for Mail folders only


if (SubFolder.Name != "Deleted Items")



GetSubFoldersAndItems(SubFolder, tvMailFolders.Nodes[i]); // See below this method’s definition





void GetSubFoldersAndItems(OutLook.MAPIFolder SubFolder, TreeNode aNode)


foreach (OutLook.MailItem item in SubFolder.Items)


if (SubFolder.Folders.Count > 0)


foreach (OutLook.MAPIFolder aFolder in SubFolder.Folders)



aNode.LastNode.ForeColor = Color.Red;

GetSubFoldersAndItems(aFolder, aNode.LastNode);



Now you can iterate all emails to show their headers, Subject and body.

foreach (OutLook.MailItem item in aSubFolder.Items)





lvEmailItems.Items[i].SubItems.Add(item.SentOn.ToLongDateString() + " " + item.SentOn.ToLongTimeString());



Now the problem was reading all headers in just one go and making an email message RFC 822 compliance which I will show in my next post how to do it… If anyone amongst you who would like to have this application/complete code, just please let me know, I can send it for you. Thanks and keep waiting for the next post.

Happy coding!


Hi All,
Today, I again come up with a very interesting problem with a very simple solution.
I have two tables, let me call the first table "A" and second table be "B". Both tables have a common column called EMAIL on which we can apply a join.
I want to select all those records which do not match Email Criteria in both tables, if this goes over your heads, let me tell rephrase this for you. It will be to SELECT ALL THOSE RECORDS WHERE A.EMAIL IS NOT EQUAL TO B.EMAIL
After careful analysis, here’s what comes in my mind and this might save your many mintues. Here’s the query…
I named it NEGATION JOIN :) Does this make sense for you people. Please do let me know if you figure out somthing is missing or wrong.
Happy coding!

The ntext data type cannot be selected as DISTINCT because it is not comparable

Hi All,

Today, I again come up with a very interesting problem. I was working on an SQL Server 2005 DB with almost 160 tables. In one of the core table, there was a field with data type "NTEXT". I wanted to apply DISTINCT on it, as I was getting duplicated records against a join applied to it. After hours I finally got the solution and here it is.

Problem: DISTINCT/GROUP BY keywords don’t work with "NTEXT" data fields. Here’s the error message I got.

"The ntext data type cannot be selected as DISTINCT because it is not comparable"

Solution: Cast NTEXT to NVARCHAR(MAX) so that it can hold the data (will not lose the data) and  then apply DISTINCT. Here’s the example.

    Select DISTINCT cast (Your Col Name as NVARCHAR(MAX))

Drawback: The one of the biggest drawback for casting is against performance. Casting can drastically reduce performance.

I hope this small post can help you and save your many hours.

Kind Regards,

I get prompt for User Name and Password, when I try to access my portal site!

When I access portal, I get prompt for username/password every time… Here’s is the way to remove it!

  1. Open internet explorer
  2. Go to Tools
  3. Click on internet option
  4. Open security tab
  5. Click on custom level
  6. Scroll down and select
  7. Select Automatic logon with current username and password
  8. Click ok

Converting Data Type of Promoted Fields with Custom Event Handlers for MOSS

Hi Again,

In my previous post titled "WORKING WITH INFOPATH FORMS AND INFOPATH SERVICES", I tried to build a guide for publishing InfoPath forms as content types and promoting few fields so that they can appear in list views. I hope the previous post was useful and helpful. Please provide your comments on that, if you think any change will make it more beneficial for all of us.

Anyways, moving on with this post, toady’s agenda is…

  • Playing with InfoPath’s promoted fields.
  • Converting DataType of promoted fields.
  • Working with an event handler.


The scenario is when we promote fields (text boxes) from InfoPath, they are promoted as single line of text. My problem was I wanted to sum the totals of all the form reimbursements from my side, as this is possible in list views, I just need to leverage my promoted fields to act like currency field instead of single line of text, so that I can apply out of box formula on it.


  1. Change the data type of promoted fields from "SINGLE LINE OF TEXT" to "CURRENCY".
  2. Apply out of box "SUM" formula to it.


After facing this problem, I surf for hours and hours and didn’t find an appropriate solution for this. I consulted a Sr. SharePoint Consultant,
Mr. Yasir Jerry (My Mentor — I LOVE YOU, MAN J), currently working in KSA, who proposed making and attaching an event handler to my SharePoint list. So here’s what I did.

  1. Go to your list in which you have your content type.
  2. Make a new view of that list and make a new field in it of currency type.
  3. Make a simple Class Library using VS 2005 and give ref of SharePoint.
  4. Make a class in it which is inherited from SPItemEventReceiver (as we are woking with List Items so need to inherit this class from there).
  5. Overrides two methods, these will fire when item is added and updated.

    public class ItemHandler : SPItemEventReceiver


    public override void ItemAdded(SPItemEventProperties properties)



    SPListItem aItem = properties.ListItem;

    aItem["Name of New Currency Field"] = aItem["Name of promoted Field"];




    public override void ItemUpdated(SPItemEventProperties properties)



    SPListItem aItem = properties.ListItem;

    aItem["Name of New Currency Field "] = aItem["Name of promoted Field "];





  6. Build the project for any errors.
  7. Sign this assembly a strong name.
  8. Build it again, and place it in GAC (Global Assembly Cache, by opening c:Windowsassembly and drag drop that DLL file from BIN folder of your class library project)
  9. Attach the custom Event Handler with list.
  10. Go to your view, add your new currency field to view and in TOTAL SECTION selects the field then select SUM.
  11. Make this field as Default View.

You are done! Enjoy J


There is no way that you change the data type of the promoted field. The only way is write custom event handler that fires on Item Change and Update and assign the value to other data type field. I hope this post will also be useful, Please provide your comments so that I make it more beneficial for people.

Working with InfoPath Forms and InfoPath Services

Hi All,

Its long time, I’m out of my blogging service, just because of the fact I didn’t get enough time to share with you people my findings. Anyways, new twist in life and I’m back. Before I would take you towards my post, I would like to share a though with all of you! Here it is…


Anyways, let me carry on with my today’s blog post. My today’s focus is on INFOPATH FORMS, PROMOTING FIELDS FROM INFOPATH FORMS AND PUBLISH THE FORM AS CONTENT TYPE. I hope this post will be helpful for you people.


The company in which I’m currently employed wants there business processes to get automated. One of the business processes is EXPENSE REIMBURSEMENTS. Let me explain a little. Employee fills a form and then it first goes to team lead (TL) for approval and if he approves it then it goes to Manager Finance in accounts department. Form looks something like this.




  1. Field indicated in Red above (Let me name them as well), "EMPLOYEENAME AND EMPLOYEEID" were supposed to come from AD and should be loaded from on form load. These fields are read only as well, so that if any employee fills a form its filled in with his/her name and ID, and read only field are required so that these cannot be changed.
  2. Total Due Amount against this reimbursement should appear in view.
  3. Bills/receipts should be attached as well.
  4. This form should appear in browser so that user can fill it there (InfoPath’s visual fidelity should be presented with zero footprint on the client)


  1. Design your form in Microsoft Word and then import it using InfoPath wizard. (Open InfoPath, you will see an IMPORT INFOPATH FORM on left side, then select "InfoPath Importer for Word Documents", browse to word document and then click FINISH) OR you can directly start designing it in InfoPath
  3. Check the check box "DESIGN A FORM TEMPLATE THAT CAN BE OPENED IN A BROWSER OR INFOPATH", this will enable the users to open and fill this form in InfoPath without any footprints of InfoPath on the client end.
  4. For Repeating tables (with X number of Rows and Y no of Columns) use control REPEATING TABLE from Controls submenu. You will find this submenu inside Design Checker.
  5. Form should look something like this
  6.  Main2
  7. Now when you are finish with designing the form, its time to publish it. But before publishing, lets name the fields which we would like to show in our views.
  8. In my case these are (Name, DueAmount). So first let me name these textboxes. Double click a textbox and set its name, here you can also set different properties like setting a formula, Data Type, Multiline, Cannot be blank, or Read Only.
  9. Ohhh! I almost forgot, to get data (EmployeeName and EmployeeID) on form load, we need to go through these steps. One way is to write a code on form load event which can prove futile for developer new to InfoPath services. Other way (easy way and involved NO CODE) is to call a web service (Provided by Microsoft J) and it will return you the required fields. Here are the steps… Please see this blog for more support [http://blogs.microsoft.co.il/blogs/itaysk/archive/2007/04/05/InfoPath-_2D00_-Get-the-current-user-without-writing-code.aspx]



    concat(Value[Name = "FirstName"], " ", Value[Name = "MiddleName"], " ", Value[Name = "LastName"])


    Please find the step-by-step snapshots below!

      1       2     3  4      5 


      2-1     2-22-3    2-42-5


    [InfoPath is great for building forms, but what about deployment? Not all of your customers will have access to the InfoPath client application—and they won’t have to. InfoPath Forms Services, which is built on top of SharePoint Server 2007, uses SharePoint document libraries, content types, permissions, and administration to deliver an integrated forms-management package. Moreover, Forms Services is designed to extend the reach of your forms. Not only does it support Microsoft Internet Explorer® on Windows, it can also serve forms to Netscape and Firefox for UNIX and Windows, and even Firefox and Safari for the Macintosh, and it can render content for mobile devices such as Smartphones and PDAs] Ref: http://msdn.microsoft.com/en-us/magazine/cc163562.aspx

MOSS Installation Error… ASP.NET should be in allowed list of IIS

Hello All,
I was installing MOSS yesterday, and was getting an error stating "ASP.NET should be in allowed list of IIS", although It was in the allowed list of IIS but the error was there…. After many re-attempts to install I found that the I need to have the 64 bit DLL for ASP.NET, and it worked for me… here’s is the solution
Goto Command Prompt:
1) Run c:WindowsMicrosoft.NETframeworkv2.0.50727aspnet_regiis -u <– uninstalls the 32 bit edition of asp.net 2.0

2) Go to c:inetpubAdminScripts and type "adsutil.vbs set w3svc/AppPools/Enable32bitAppOnWin64 0" from the cmd prompt <–this disables 32 bit mode in IIS

3) Run c:windowsframeworkv2.0.50727aspnet_regiis -i 

4) Reset IIS

5) Install MOSS.

Shocking News…. I left XAVOR Pakistan Pvt Ltd

Hi All,
Today I am going to tell a shocking news to all of you! I left XAVOR Pakistan Pvt Ltd. Sad (a very famous Software house in Lahore) only after working few months there and now working for COMSATS Institute of Information Technology where I am going to develop MOSS based portal for students and teacher…. INTERESTING Smile
Keep Praying!!! Really need them now!
Thanks and Regards…. Muneeb

Making Site Definition Templates for MOSS 2007

  1. Go to C:Program FilesCommon FilesMicrosoft Sharedweb server extensions12TEMPLATESiteTemplates
  2. Copy SPSTOPIC or SPSTOC and rename it as you would like
  3. Open your custom template in your favorite XML browser (in my case it would be VS.NET 2005)
  4. Collapse NAVBARS, LIST TEMPLATES and DOCUMENT TEMPLATES section (Means don’t do any change in them)
  5. In the lists section of Configuration Element make this entry

<List Title="Your Title" Description="Your Description" Url="Document Library" Type="XXXX" FeatureId="XXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXX"></List>  


  • Where Feature ID is the GUID of your Custom Feature.
  • Type is the feature type mentioned in ElementMainfest.xml file of the feature
  • URL is the URL for this list

 You can write as many list tag as you would like.

NOTE: If you want two instances of same feature you should make two entries in ElementManifest.xml file of that feature and make one entry hidden so that it wont appear in Create Lists page of your custom site.

6. Under WebFeatures Element under this <Feature ID="00BFEA71-4EA5-48D4-A4AD-7EA5C011ABE5" /> tag mention your custom features by copying this default feature tag (Don’t delete it… Its Team Collab Feature which is new in MOSS 2007 which has all build in features like Announcements, Links List, Tasks etc)

 7. In the file section under module element make this entry (If you wish to see your custom list appear on default page when you create a site)

 <View List="XXXX" BaseViewID="1" WebPartZoneID="MiddleRightZone" WebPartOrder="3"/>


  • Where Value XXXX should be same given above for Type attribute
  • Mention the zone and order in which you want to show it

 8. Don’t forget to make its entry in WEBTEMPSPS.xml file which is in folder C:Program FilesCommon FilesMicrosoft Sharedweb server extensions12TEMPLATE1033XML

<Template Name="SITE DEFINITION FOLDER NAME" ID="10042"><Configuration ID="0" Title="Any Title" Type="0" Hidden="FALSE" ImageUrl="/_layouts/images/stsprev.png" Description="Any Description" DisplayCategory="Any"></Configuration></Template>


  • ID should be greater than 10000 for custom templates
  • Name should be same as folder name of custom site definition

Restart IIS, make a new site and enjoy!!!



The URL Library Name/File Name is invalid. It may refer to a nonexistent file or folder, or refer to a valid file or folder that is not in the current Web.


When you try to upload or check in a document in the document Library in newly migrated document library you get this error message.

The URL Library Name/File Name is invalid. It may refer to a nonexistent file or folder, or refer to a valid file or folder that is not in the current Web.


  1. When an item is added in a document library a stored procedure is called in SQL Server 2000 or 2005 this procedure requires some parameter which are send many times (may be twice or thrice), which can be checked in the log file, the entry is like this….

     Additional error information from SQL Server is included below. "Parameter ‘@nvarchar12’ was supplied multiple times." Query text (if available): "DECLARE @@S uniqueidentifier; DECLARE @@W uniqueidentifier; ……………………. 

     2.     Same Column Name might be given to two or more columns in Schema.XML file of your custom feature.


  • Simply open the Schema.XML file in your favorite XML Editor (in my case it will be VS 2005)
  • Delete the tag ColName="nvarcharX" where X is an integer value
  • Save the Schema.XML file
  • Re-install feature by using command line (stsadm –o installfeature –name FEATURENAME -force)
  • Restart IIS
  • Revert the site
  • Redo migration and you are done with it

 Looking forward,

Ahmed Muneeb

How to make two instances of your custom feature?

Hi All,

Today I will discuss how to make two instances of your custom feature in your site definition file

NOTE: This entry is for SharePoint 2007…. Moreover I am assuming that you have some prior knowledge of how to create your custom Site Definitions…

  1. Make your custom Feature using XML or Solution generator.
  2. Solution generator will generate the schema and all the aspx pages that are required by that feature.
  3. For Solution generator to work you need to install Visual Studio 2005 and at least Windows SharePoint Services 3.0
  4. Go to Element Manifest from the folder… 12TemplatesFeaturesCustomFeatureListTemplates
  5. Edit the Element Manifest.XML file in any XML Editor (in my case I prefer VS 2005)
  6. Make a new entry by copying the entry which is already present there and changing its type.
  7. Save the file and you are done
  8. Re-install the feature by using command line command stsadm –o installfeature –name FeatureName –force
  9. Restart IIS
  10. Create a new site then go to Manage Site Content appearing on the left side above Quick Launch and then click create from the top there you see two instances of same feature.

Difference between Abstract Class and Interface with feature comparisons

What is an Abstract class?

An abstract class is a special kind of class that cannot be instantiated. So the question is why we need a class that cannot be instantiated? An abstract class is only to be sub-classed (inherited from). In other words, it only allows other classes to inherit from it but cannot be instantiated. The advantage is that it enforces certain hierarchies for all the subclasses. In simple words, it is a kind of contract that forces all the subclasses to carry on the same hierarchies or standards.

What is an Interface?

An interface is not a class. It is an entity that is defined by the word Interface. An interface has no implementation; it only has the signature or in other words, just the definition of the methods without the body. As one of the similarities to Abstract class, it is a contract that is used to define hierarchies for all subclasses or it defines specific set of methods and their arguments. The main difference between them is that a class can implement more than one interface but can only inherit from one abstract class. Since C# doesn’t support multiple inheritance, interfaces are used to implement multiple inheritance.

Both together

When we create an interface, we are basically creating a set of methods without any implementation that must be overridden by the implemented classes. The advantage is that it provides a way for a class to be a part of two classes: one inheritance hierarchy and one from the interface.

When we create an abstract class, we are creating a base class that might have one or more completed methods but at least one or more methods are left uncompleted and declared abstract. If all the methods of an abstract class are uncompleted then it is the same as an interface but with the restriction that it cannot make a class inherit from it. The purpose of an abstract class is to provide a base class definition for how a set of derived classes will work and then allow the programmers to fill the implementation in the derived classes.

There are some similarities and differences between an interface and an abstract class that I have arranged in a table for easier comparison:



Abstract class

Multiple inheritance

A class may inherit several interfaces.

A class may inherit only one abstract class.

Default implementation

An interface cannot provide any code, just the signature.

An abstract class can provide complete, default code and/or just the details that have to be overridden.


Only Static final constants.

Both instance and static constants are possible.

Core VS Peripheral

Interfaces are used to define the peripheral abilities of a class. In other words both Human and Vehicle can inherit from a IMovable interface.

An abstract class defines the core identity of a class and there it is used for objects of the same type.


If the various implementations only share method signatures then it is better to use Interface.

If the various implementations are of the same kind and use common behaviour or status then abstract class is better to use.


Requires more time to find the actual method in the corresponding classes.


Adding functionality

If we add a new method to an Interface then we have to track down all the implementations of the interface and define implementation for the new method.

If we add a new method to an abstract class then we have the option of providing default implementation and therefore all the existing code might work properly.

Installing and Configuring SharePoint Portal Server 2003

 Installing and Configuring SharePoint Portal Server 2003

Installation Steps

  1. Install Windows Server 2003 with SP1
  2. Install SQL Server 2000 with SP4
  3. Install IIS 6.0 with ASP.NET from WINDOWS COMPONENTS in ADD/REMOVE softwares in the CONTROL PANNEL
  4. Install Windows SharePoint Portal Server 2003 from Setup file

Configuration Steps

  1. After first few steps setup will ask for the following options
    1. With Database Engine
    2. Without Database Engine
  2. Select Without Database Engine
  3. After the installation is finished go to SharePoint Central Administration
    1. 1st Step: Give your account and password in the second window
    2. 2nd Step: Select create Configuration DB and select Server Name and select “Use Default Name”
    3. 3rd Step: Give your email like amuneeb@xavor.com
  4. Click Change components and check all boxes from top and then close it
  5. After these steps if you want to go to SharePoint portal it will show message “Under construction”
  6. So go to Central Administration and select Create a Portal Site give its name etc and then the portal Site is created.


Keep Enjoying

Creating Site Definitions for WSS

Hi Guys!!!
Here is a great article by Microsoft on Site Definitions using Windows SharePoint Services!!! Please do read it line by line

Creating Site Definitions for Windows SharePoint Services


Encapsulation, Inheritance, Polymorphism, Abstraction

Encapsulation is the process of grouping the methods and variables into a class that represents the fields an object stores and the operations the object performs to accomplish specific tasks.
Inheritance is the ability to create a new class based on the existing methods and class variables in order to extend the functionality of the base class.
Polymorphism is the ability of an object to change forms as the program executes. A polymorphic computer object, e.g Might changed from Server to Workstation as the program executes
Abstraction provides the programmer with the ability to temporarily ignore an object’s underlying details, while a programmer builds a solution.
Resource: VB.NET Tips and Techniques Kris Jamsa

How to add Folders and SubFolders in TreeView

The following code helps you to get folders and subfolders in a treeview
Imports System.IO
 Private Sub btnBrowse_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnBrowse.Click
        Dim FBD As New FolderBrowserDialog
        txtSelectedPath.Text = FBD.SelectedPath.ToString
        tvFoldernFiles.Nodes.Add(txtSelectedPath.Text.ToString, txtSelectedPath.Text)
        GetFilesnFolders(txtSelectedPath.Text.ToString, tvFoldernFiles.Nodes(txtSelectedPath.Text))
        Dim a As String() = tvFoldernFiles.TopNode.Text.Split("".ToCharArray)
        tvFoldernFiles.TopNode.Text = a(a.Length – 1).ToString.ToUpper
    End Sub
    Public Sub GetFilesnFolders(ByVal FolderName As String, ByVal RefNode As TreeNode)
        Dim FolderList As Array = Directory.GetDirectories(FolderName.ToString)
        Dim FileListofRoot As Array = Directory.GetFiles(FolderName.ToString)
        For int As Integer = 0 To FileListofRoot.Length – 1
            Dim RootFile As New TreeNode(FileListofRoot(int).ToString)
        For i As Integer = 0 To FolderList.Length – 1
            Dim TempNode As New TreeNode(FolderList(i).ToString.ToUpper)
            Dim FileList As Array = Directory.GetFiles(FolderList(i).ToString)
            GetFilesnFolders(FolderList(i), TempNode)
    End Sub

How to control Mdi child forms!!!

Write this code in the constructor of the parent form!!!
  Public Sub New()

        Me.eForm = New EmployeeForm()
        eForm.MdiParent = Me
    End Sub
 Private eForm As EmployeeForm          (Declare it at constructor level!!!)

How to add combo box in ListView

AOA, All…. if you want to add a combo box in listview…. you have to use the bound property of listview item to get the rectangular height of the combo box, here is the code which is tested and is correct…. You need a listview named listview1 with only one column
You will need to add some item in the listview1 (can be added at runtime or at design time)
For each listviewitem as listviewitem in listview1.items
Dim Combo as new combobox
combo.items.add("Ahmed Muneeb is good Programmer")
combo.dropdownstyle = dropdownlist
combo.location= new point(item.bounds.right,item.bounds.y)
Check it out it really work

How to get Top Level Sites….

Public Sub GetTopSites() ‘—- This Function Gets the Root Webs —-‘

selectedVs =

New Uri(childexplorer.CmbVirtualServers.SelectedItem.ToString)


SPVirtualServer = SPGlobalAdmin.OpenVirtualServer(selectedVs)

For Each Rootweb As SPSite In SPVirtualServer.Sites



End Sub

How to get List Items in ListView

This Code Helps you to get the List items in List View Control…… use both these functions…. first function will populate the List Fields and Second will get the List Field Values……

Public Sub GetListHeaders(ByVal caller As Uri) ‘—This Function Gets All Field Titles and Make them Columns of ListView —‘

spsite =

New SPSite(caller.ToString)




Dim splist As SPList

splist = spsite.OpenWeb.Lists(childexplorer.TvSites.SelectedNode.Text)

For Each SPField As SPField In splist.Fields ‘ —Get All Fields —‘

If (SPField.Title <> "Edit") Then


End If


Catch ex As Exception


End Try

End Sub

Public Sub GetListItems(ByVal caller As Uri) ‘—This Function Gets Items of Selected List —‘

Tryim FieldCount As Integer = 0

Dim i As Integer = 1

Dim ListItemIndex As Integer = 0

Dim SpList As SPList

Dim SelectedListItem As String = ""

SelectedListItem = childexplorer.TvSites.SelectedNode.Text.ToString


spsite =

New SPSite(caller.ToString)

SpList = spsite.OpenWeb.Lists(childexplorer.TvSites.SelectedNode.Text)

If (SpList.Items.Count > 0) Then

For Each splistitem As SPListItem In SpList.Items




MessageBox.Show("No List item in " + SpList.Title.ToString, "Information", MessageBoxButtons.OK, MessageBoxIcon.Information)

End If

Select Case SelectedListItem

Case "My Discussion Board"

For Each item As ListViewItem In childexplorer.LvListItems.Items

ListItemIndex = item.Index

FieldCount = SpList.Fields.Count

If (SpList.Items.Count > 0) Then

For Each splistitem As SPListItem In SpList.Items

If (splistitem(0) = item.Text) Then

For i = 1 To FieldCount – 3

If (splistitem.Item(i) <> Nothing) Then


ElseIf (splistitem.Item(i) = True) Then



ElseIf (splistitem.Item(i) = Nothing) Then


ElseIf (splistitem.Item(i) = False) Then



End If


End If


End If


Case Else

For Each item As ListViewItem In childexplorer.LvListItems.Items

ListItemIndex = item.Index

FieldCount = SpList.Fields.Count

If (SpList.Items.Count > 0) Then

For Each splistitem As SPListItem In SpList.Items

If (splistitem(0) = item.Text) Then

For i = 1 To FieldCount – 2

If (splistitem.Item(i) <> Nothing) Then


ElseIf (splistitem.Item(i) = True) Then



ElseIf (splistitem.Item(i) = Nothing) Then



ElseIf (splistitem.Item(i) = False) Then



End If


End If


End If


End Select

Catch ex As Exception


End Try

End Sub

How to Search List Items of Windows SharePoint Services

This code searches through WSS(Windows SharePoint Services) for Specific List Item…. by Title…….

For Each SPVirtualServer In SPGlobalAdmin.VirtualServers

If (SPVirtualServer.State = SPVirtualServerState.Ready) And (SPVirtualServer.ContentDatabases.Count > 0) And (SPVirtualServer.Description <> "Adminstration") Then

For Each spsite In SPVirtualServer.Sites

For Each spweb As SPWeb In spsite.AllWebs

For Each splist As SPList In spweb.Lists

If (splist.Items.Count > 0) Then

For Each SPListItem As SPListItem In splist.Items

If (SPListItem.Item("Title") = itemname) Then



i = i + 1

End If


End If




End If


If (i = 0) Then


"List Item not found", "Item not found", MessageBoxButtons.OK, MessageBoxIcon.Information)



"Search complete…", "Search Complete", MessageBoxButtons.OK, MessageBoxIcon.Information)

End If

New CV Link Updated on 18th Oct, 2006

Hi All, this is new link to my CV just click and see my updated achievements and what i did in last 4 years

How to Delete SubSite of Selected Site….

Hi… This Code deletes the selected subsite of a site….. check it out very helpful

Dim res As DialogResult

Dim strwebname As String = ""


res = MessageBox.Show("Are you sure you want to delete subsite " + Selrootweb.ToString, "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question)

If (res = Windows.Forms.DialogResult.Yes) Then

strwebname = spsite.OpenWeb.Name.ToString

selweb =

New Uri(TvSites.SelectedNode.Parent.Text.ToString)

spsite =

New SPSite(selweb.ToString)


MessageBox.Show("Deleted Successfully", "SubSite Deleted", MessageBoxButtons.OK, MessageBoxIcon.Information)



Dim frmmain As New frmExplorer


End If

Catch ex As Exception


"Cannot deleted site that contains subsites", "SubSite NOT Deleted", MessageBoxButtons.OK, MessageBoxIcon.Error)

End Try