<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Rehman Gul [MVP, MCTS SharePoint]</title>
	<atom:link href="http://rehmangul.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://rehmangul.wordpress.com</link>
	<description>SharePoint Blog (with a new look)</description>
	<lastBuildDate>Wed, 25 Nov 2009 03:28:09 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<cloud domain='rehmangul.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://www.gravatar.com/blavatar/2c7d43e6d551d8bc9b18d83cd660230c?s=96&#038;d=http://s.wordpress.com/i/buttonw-com.png</url>
		<title>Rehman Gul [MVP, MCTS SharePoint]</title>
		<link>http://rehmangul.wordpress.com</link>
	</image>
			<item>
		<title>WSPBuilder Error</title>
		<link>http://rehmangul.wordpress.com/2009/11/20/wspbuilder-error/</link>
		<comments>http://rehmangul.wordpress.com/2009/11/20/wspbuilder-error/#comments</comments>
		<pubDate>Fri, 20 Nov 2009 06:32:39 +0000</pubDate>
		<dc:creator>rehmangul</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://rehmangul.wordpress.com/?p=403</guid>
		<description><![CDATA[In Visual Studio, while you try to build wsp using WSPBuilder, you receive an error message saying:

========== Build: 1 succeeded or up-to-date, 0 failed, 0 skipped ==========
WSPBuilder
Version: 0.9.8.0830
Created by Carsten Keutmann
GPL License 2007
Building the solution - please wait
Saving the Manifest.xml file
Creating the WSP file
Could not load file or assembly 'CabLib, Version=6.9.26.0, Culture=neutral, PublicKeyToken=85376ef9a48d191a' or one [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=rehmangul.wordpress.com&blog=637369&post=403&subd=rehmangul&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p></br>In Visual Studio, while you try to build wsp using WSPBuilder, you receive an error message saying:</p>
<p><code><br />
========== Build: 1 succeeded or up-to-date, 0 failed, 0 skipped ==========<br />
WSPBuilder<br />
Version: 0.9.8.0830<br />
Created by Carsten Keutmann<br />
GPL License 2007<br />
Building the solution - please wait<br />
Saving the Manifest.xml file<br />
Creating the WSP file<br />
Could not load file or assembly 'CabLib, Version=6.9.26.0, Culture=neutral, PublicKeyToken=85376ef9a48d191a' or one of its dependencies. An attempt was made to load a program with an incorrect format.<br />
</code><br />
<strong>Fix: </strong></p>
<p>Problem occurs when you try to use x64 version of WSPBuilder on x86 machine (usually happens on VMs). </p>
<p>This happens because you have a wrong cablib.dll (x64 instead of x86) in wsp builder&#8217;s installation directory. Get x86 cablib.dll and copy/paste it in the installation directory of wsp builder (overwrite the old cablib.dll), usually at C:\Program Files\WSPTools\WSPBuilderExtensions.</p>
<p>If you do not have cablib.dll for x86 platform, get appropriate version (x86) of wsp builder and that comes with appropriate (x86) cablib.dll.</p>
<p>Hope this helps&#8211;</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/rehmangul.wordpress.com/403/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/rehmangul.wordpress.com/403/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/rehmangul.wordpress.com/403/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/rehmangul.wordpress.com/403/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/rehmangul.wordpress.com/403/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/rehmangul.wordpress.com/403/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/rehmangul.wordpress.com/403/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/rehmangul.wordpress.com/403/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/rehmangul.wordpress.com/403/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/rehmangul.wordpress.com/403/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=rehmangul.wordpress.com&blog=637369&post=403&subd=rehmangul&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://rehmangul.wordpress.com/2009/11/20/wspbuilder-error/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/91d0677ad58d84af0a601b52b33e250c?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">rehmangul</media:title>
		</media:content>
	</item>
		<item>
		<title>Writing Event Handlers and Attaching/Detaching using Features</title>
		<link>http://rehmangul.wordpress.com/2009/11/17/writing-event-handlers-and-deploying-using-features/</link>
		<comments>http://rehmangul.wordpress.com/2009/11/17/writing-event-handlers-and-deploying-using-features/#comments</comments>
		<pubDate>Tue, 17 Nov 2009 01:08:11 +0000</pubDate>
		<dc:creator>rehmangul</dc:creator>
				<category><![CDATA[MOSS]]></category>
		<category><![CDATA[MS SharePoint Sever]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[error]]></category>
		<category><![CDATA[event handlers]]></category>
		<category><![CDATA[sharepoint]]></category>
		<category><![CDATA[sps]]></category>
		<category><![CDATA[Coding SharePoint]]></category>
		<category><![CDATA[Custom Sharepoint]]></category>
		<category><![CDATA[customise]]></category>
		<category><![CDATA[event handler]]></category>
		<category><![CDATA[Feature]]></category>
		<category><![CDATA[moss customisation]]></category>
		<category><![CDATA[SharePoint Customization]]></category>
		<category><![CDATA[sharepoint features]]></category>
		<category><![CDATA[tips and tricks]]></category>
		<category><![CDATA[workarounds]]></category>

		<guid isPermaLink="false">http://rehmangul.wordpress.com/?p=319</guid>
		<description><![CDATA[

In this post, I am going to write an event handler that:

is triggered when an item is added to a document library (i.e. ItemAdded)
sends an email to some email address notifying that an item has been added to the document library
is deployed to a List using SharePoint Features

Okey, lets get started. Create a subsite under your site [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=rehmangul.wordpress.com&blog=637369&post=319&subd=rehmangul&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p style="text-align:left;"><a href="http://rehmangul.files.wordpress.com/2009/11/email-itself1.jpg"></a></p>
<p></br></p>
<p>In this post, I am going to write an event handler that:</p>
<ol>
<li>is triggered when an item is added to a document library (i.e. ItemAdded)</li>
<li>sends an email to some email address notifying that an item has been added to the document library</li>
<li>is deployed to a List using SharePoint Features</li>
</ol>
<p>Okey, lets get started. Create a subsite under your site collection. In the subsite create a Document Library named AlertMe.</p>
<p>JumpStart &#8211; &gt; JumpStartWeb -&gt; AlertMe <br /></br><br /></br></p>
<p style="text-align:center;"><img class="size-full wp-image-321 aligncenter" title="homepage show" src="http://rehmangul.files.wordpress.com/2009/11/homepage-show1.jpg?w=564&#038;h=445" alt="homepage show" width="564" height="445" /></p>
<p><strong> </strong></p>
<p><strong>Create the Event Handler:</strong></p>
<p>Go to Visual Studio 2008. Click File -&gt; New -&gt; Project &#8230;..and select Class Library:<br /></br><br /></br></p>
<p> 
<p style="text-align:center;"><img class="size-full wp-image-328 aligncenter" title="create proj scr1" src="http://rehmangul.files.wordpress.com/2009/11/create-proj-scr11.jpg?w=600&#038;h=250" alt="create proj scr1" width="600" height="250" /></p>
<p></br><br /></br></p>
<p></br><br /></br>Give any name to your project e.g. &#8221;EventHandler.SharePoint.SendEmail.Feature&#8221;. This will also become the name of your namespace<br /></br><br /></br></p>
<p style="text-align:center;"><img class="size-full wp-image-350 aligncenter" title="enter proj name" src="http://rehmangul.files.wordpress.com/2009/11/enter-proj-name.jpg?w=600&#038;h=456" alt="enter proj name" width="600" height="456" /></p>
<p></br><br /></br></p>
<p>Add the directives as shown below:<br /></br><br /></br></p>
<p style="text-align:center;"><img class="size-full wp-image-329 aligncenter" title="add reference 4 with all screen changes" src="http://rehmangul.files.wordpress.com/2009/11/add-reference-4-with-all-screen-changes.jpg?w=503&#038;h=421" alt="add reference 4 with all screen changes" width="503" height="421" /></p>
<p></br><br /></br></p>
<p>Top four directives will already be there.
<ol>
<li>&#8220;Microsoft.SharePoint&#8221; is to use sharepoint object model.
<li>&#8220;System.Reflection&#8221; is to get assembly information as we will need that to register the event handler with the document library.
<li>&#8220;Microsoft.SharePoint.Utilities&#8221; is to send email from SharePoint. </li>
</ol>
<p></br>Your namespace name is the name you selected for your project. Rename Class1 to &#8220;EmailAlertsEventHandler&#8221; and make it to inherit from SPItemEventReceiver class. Rename the class in Solution Explorer window as well:<br /></br><br /></br></p>
<p style="text-align:center;"><a href="http://rehmangul.files.wordpress.com/2009/11/rename-class.jpg"><img class="size-full wp-image-352 aligncenter" title="rename class" src="http://rehmangul.files.wordpress.com/2009/11/rename-class.jpg?w=276&#038;h=213" alt="" width="276" height="213" /></a></p>
<p></br><br /></br></p>
<p>You might have noted that SPItemEventReceiver class name appears in black coloured font, that&#8217;s because we are missing a reference to Windows SharePoint Services.</p>
<p>Lets add the reference as shown below:<br /></br><br /></br></p>
<p style="text-align:center;"><img class="size-full wp-image-330 aligncenter" title="references" src="http://rehmangul.files.wordpress.com/2009/11/references.jpg?w=352&#038;h=300" alt="references" width="352" height="300" /></p>
<p></br><br /></br></p>
<p>Right click &#8220;References&#8221; -&gt; in the Solution Explorer window and click Add Reference.</p>
<p>Select Windows SharePoint Services as shown below:<br /></br><br /></br></p>
<p style="text-align:center;"><img class="size-full wp-image-331 aligncenter" title="select WSS" src="http://rehmangul.files.wordpress.com/2009/11/select-wss.jpg?w=467&#038;h=381" alt="select WSS" width="467" height="381" /></p>
<p></br><br /></br></p>
<p>As soon as you will add this reference, Microsoft.SharePoint will appear under References and SPItemEventReceiver will change its colour to green which means that it is recognized as a class now.</p>
<p>If you want to see what SPItemEventReceiver contains, press Alt+Cntrl+j, Object Browser window will open. Expand Microsoft.SharePoint -&gt; Microsoft.SharePoint -&gt; SPItemEventReceiver. You will see all the methods in this class in the right hand pane. You will also see the ItemAdded method which we are going to use for our event handler.<br /></br><br /></br></p>
<p style="text-align:center;"><img class="size-full wp-image-332 aligncenter" title="obj browser" src="http://rehmangul.files.wordpress.com/2009/11/obj-browser.jpg?w=600&#038;h=433" alt="obj browser" width="600" height="433" /></p>
<p></br><br /></br></p>
<p>Alright, lets add a few methods to our class. As you will write &#8220;public override&#8221; and press space, intellisence will provide for you the list of all methods available in SPItemEventReceiver, as we saw in the Object Browser:<br /></br><br /></br></p>
<p style="text-align:center;"><img class="size-full wp-image-333 aligncenter" title="methods auto appear" src="http://rehmangul.files.wordpress.com/2009/11/methods-auto-appear.jpg?w=542&#038;h=303" alt="methods auto appear" width="542" height="303" /></p>
<p></br><br /></br></p>
<p>Select ItemAdded from the list and enjoy the intelligence of VS, you will find a few things automatically done for you:<br /></br><br /></br></p>
<p style="text-align:center;"><img class="size-full wp-image-334 aligncenter" title="auto para and base call" src="http://rehmangul.files.wordpress.com/2009/11/auto-para-and-base-call.jpg?w=600&#038;h=268" alt="auto para and base call" width="600" height="268" /></p>
<p></br><br /></br></p>
<p>Here is the  code for &#8220;EmailAlertsEventHandler.cs&#8221;:</p>
<p><code><br />
using System;<br />
using System.Collections.Generic;<br />
using System.Linq;<br />
using System.Text;<br />
using Microsoft.SharePoint;<br />
using System.Reflection;<br />
using Microsoft.SharePoint.Utilities;</p>
<p>namespace EventHandler.SharePoint.SendEmail.Feature<br />
{<br />
    public class EmailAlertsEventHandler : SPItemEventReceiver<br />
    {<br />
        public override void <strong>ItemAdded</strong>(SPItemEventProperties properties)<br />
        {<br />
            base.ItemAdded(properties);<br />
           <br />
            SPListItem myItem = properties.ListItem;<br />
            try<br />
            {<br />
                SPSecurity.RunWithElevatedPrivileges(delegate()<br />
                {<br />
                    using (SPSite site = new SPSite(properties.WebUrl))<br />
                    {<br />
                        using (SPWeb web = site.OpenWeb())<br />
                        {<br />
                            string emailSubject = "New Items Added to JumpStart";       <br />
                            string emailBody = myItem.Name.ToString() +<br />
                                " has been added to AlertMe Document Library for your review." + "\n" +<br />
                                "\n" + "Thanks," + "\n" + "JumpStart EmailAlertsEventHandler!";<br />
                            SPUtility.SendEmail(web, true, true, "rehman.gul@hotmail.com", emailSubject, emailBody);   <br />
                        }<br />
                    }<br />
                });<br />
            }<br />
            catch (Exception ex)<br />
            {<br />
               <br />
            }<br />
        }<br />
       <br />
        public static void <strong>AddOrRemoveEventHandler</strong>(SPList list, bool doAdd)<br />
        {<br />
            Assembly asm = Assembly.GetExecutingAssembly();<br />
            string className = typeof(EmailAlertsEventHandler).FullName;</p>
<p>            if (doAdd)<br />
            {<br />
                SPEventReceiverDefinition eventDef = list.EventReceivers.Add();<br />
                eventDef.Type = SPEventReceiverType.ItemAdded;<br />
                eventDef.Assembly = asm.FullName;<br />
                eventDef.Class = className;<br />
                eventDef.Name = className + "." + eventDef.Type.ToString();<br />
                eventDef.SequenceNumber = 10001;<br />
                eventDef.Data = null;<br />
                eventDef.Update();<br />
            }<br />
            else<br />
            {<br />
                List&lt;SPEventReceiverDefinition&gt; eventsToDelete = new List&lt;SPEventReceiverDefinition&gt;();<br />
                foreach (SPEventReceiverDefinition eventDef in list.EventReceivers)<br />
                {<br />
                    if (eventDef.Assembly == asm.FullName &amp;&amp; eventDef.Class == className)<br />
                    {<br />
                        eventsToDelete.Add(eventDef);<br />
                    }<br />
                }<br />
                foreach (SPEventReceiverDefinition eventDef in eventsToDelete)<br />
                {<br />
                    eventDef.Delete();<br />
                }<br />
            }<br />
        }<br />
    }<br />
}</p>
<p></code><br />
As you can see in the code above, there are only two functions ItemAdded and AddOrRemoveEventHandler. ItemAdded opens the web, gets the name of the item which invokes the event handler and sends an email to the specified address. AddOrRemoveEventHandler adds the event handler to the list or removes it, depending on the bool value &#8220;doAdd&#8221;.</p>
<p><strong>Create the Feature Receiver:</strong></p>
<p>Now how do we attach this Event Handler with a specific list. For that we said we will use Features, such that when the feature is activated, the event handler is attached to our list, and when the feature is deactivated, the event handler is detached from the list.</p>
<p>So, we have to write some code to capture Activate and Deactivate events of the feature. Right click on your project in the solution explorer -&gt; Add -&gt; Class &#8230;&#8230;&#8230;..as shown below:<br /></br><br /></br></p>
<p style="text-align:center;"><img class="size-full wp-image-338 aligncenter" title="add new class" src="http://rehmangul.files.wordpress.com/2009/11/add-new-class.jpg?w=379&#038;h=482" alt="add new class" width="379" height="482" /></p>
<p></br><br /></br></p>
<p>Select Class, give it a name like EmailAlertsFeatureInstaller:<br /></br><br /></br></p>
<p style="text-align:center;"><a href="http://rehmangul.files.wordpress.com/2009/11/feature-installer-add-scr1.jpg"><img class="size-full wp-image-354 aligncenter" title="feature installer add scr" src="http://rehmangul.files.wordpress.com/2009/11/feature-installer-add-scr1.jpg?w=593&#038;h=411" alt="" width="593" height="411" /></a><a href="http://rehmangul.files.wordpress.com/2009/11/feature-installer-add-scr.jpg"></a></p>
<p></br><br /></br></p>
<p>Add the directives Microsoft.SharePoint, System.Reflection and Microsoft.SharePoint.Utilities on the top as shown below. Inherit the class EmailAlertsFeatureInstaller from SPFeatureReceiver. You can open the Object Browser to see all the methods available in SPFeatureReceiver..<br /></br><br /></br></p>
<p style="text-align:center;"><img class="size-full wp-image-339 aligncenter" title="new class with intelli and func" src="http://rehmangul.files.wordpress.com/2009/11/new-class-with-intelli-and-func.jpg?w=568&#038;h=329" alt="new class with intelli and func" width="568" height="329" /></p>
<p></br><br /></br></p>
<p>Before I move to add methods to this class, lemme explain what is SPFeatureReceiver doing here. Every feature can have four events i.e Feature Activation, Feature Deactivation, Feature Installation and Feature Uninstallation. Against these four events, SPFeatureReceiver class provides us with four methods respectively i.e. FeatureActivated, FeatureDeactivating, FeatureInstalled and FeatureUninstalling. These methods will be executed as the events take place. So, if we override these methods and put our custom code inside, our custom code will be executed whenever a feature is activated, deactivated, installed or uninstalled.</p>
<p>And thats what we wanted i.e. when a feature is Activated, our event handler gets attached to our AlertMe document library. And when the feature is Deactivated, our event handler is detached from our AlertMe document library.</p>
<p>Here is the full code for EmailAlertsFeatureInstaller.cs:</p>
<p><code><br />
using System;<br />
using System.Collections.Generic;<br />
using System.Linq;<br />
using System.Text;<br />
using Microsoft.SharePoint;<br />
using System.Reflection;<br />
using Microsoft.SharePoint.Utilities;</p>
<p>namespace EventHandler.SharePoint.SendEmail.Feature<br />
{<br />
    class EmailAlertsFeatureInstaller : SPFeatureReceiver<br />
    {<br />
        public override void <strong>FeatureActivated</strong>(SPFeatureReceiverProperties properties)<br />
        {<br />
            SPSecurity.RunWithElevatedPrivileges(delegate()<br />
            {<br />
                using (SPWeb web = (SPWeb)properties.Feature.Parent)<br />
                {<br />
                        SPList list = web.Lists["AlertMe"];<br />
                        EmailAlertsEventHandler.AddOrRemoveEventHandler(list, true);<br />
                }<br />
             });<br />
        }</p>
<p>        public override void <strong>FeatureDeactivating</strong>(SPFeatureReceiverProperties properties)<br />
        {<br />
            SPSecurity.RunWithElevatedPrivileges(delegate()<br />
            {<br />
                using (SPWeb web = (SPWeb)properties.Feature.Parent)<br />
                {<br />
                    List&lt;SPList&gt; webLists = new List&lt;SPList&gt;();<br />
                    foreach (SPList list in web.Lists)<br />
                    {<br />
                        webLists.Add(list);<br />
                    }</p>
<p>                    foreach (SPList list in webLists)<br />
                    {<br />
                        EmailAlertsEventHandler.AddOrRemoveEventHandler(list, false);<br />
                    }<br />
                }<br />
            });<br />
        }</p>
<p>        public override void FeatureInstalled(SPFeatureReceiverProperties properties)<br />
        {<br />
        }</p>
<p>        public override void FeatureUninstalling(SPFeatureReceiverProperties properties)<br />
        {<br />
        }<br />
       <br />
    }<br />
}</p>
<p></code><br />
As you can see we have overriden only two methods of SPFeatureReceiver class i.e. FeatureActivated and FeatureDeactivating. On FeatureActivated we get to our list AlertMe and call AddOrRemoverEventHandler with a &#8216;true&#8217; value i.e. attach the event handler. On FeatureDeactivating we iterate through all the lists and call AddOrRemoveEventHandler with a &#8216;false&#8217; value i.e. detach the event handler.</p>
<p>Also, you can see above in the code that we have added FeatureInstalled and FeatureUninstalling methods though there is no functionality added to them. This is mandatory, if you will not add these methods you will receive an error message because these are abstract members of SPFeatureReceiver class and we must implement them in our class.  </p>
<p>Alright we are ready to build our project. Try building and it should work.</p>
<p><strong>Put your assembly in the GAC:</strong></p>
<p>Now lets put our assembly (dll) in Global Assembly Cache (GAC) so that it is available to SharePoint. For that we have to strongly name our assembly as it will be placed in a shared location (GAC).</p>
<p>To strongly name your assembly, right click on your project in Solution Explorer window and click Properties:<br /></br><br /></br></p>
<p style="text-align:center;"><img class="size-full wp-image-335 aligncenter" title="sign 1" src="http://rehmangul.files.wordpress.com/2009/11/sign-1.jpg?w=312&#038;h=496" alt="sign 1" width="312" height="496" /></p>
<p></br><br /></br></p>
<p>Select Signing at the bottom and fill the check box saying &#8220;Sign the assembly&#8221;. In &#8220;Choose a stong name key file&#8221; drop down, select &lt;New&#8230;&gt;. In &#8220;Key file name&#8221; text box, give name of your project (assembly) like &#8220;EventHandler.SharePoint.SendEmail.Feature&#8221;&#8230;&#8230;..click OK&#8230;&#8230;.as shown below:<br /></br><br /></br></p>
<p style="text-align:center;"><img class="size-full wp-image-336 aligncenter" title="sign 2" src="http://rehmangul.files.wordpress.com/2009/11/sign-2.jpg?w=525&#038;h=502" alt="sign 2" width="525" height="502" /></p>
<p></br><br /></br></p>
<p>You will that a file named &#8220;EventHandler.SharePoint.SendEmail.Feature.snk&#8221; has been added to our project. If you click the file, you will see something similar:<br /></br><br /></br></p>
<p style="text-align:center;"><img class="size-full wp-image-337 aligncenter" title="key code" src="http://rehmangul.files.wordpress.com/2009/11/key-code.jpg?w=510&#038;h=511" alt="key code" width="510" height="511" /></p>
<p></br><br /></br></p>
<p>Now our assembly is ready to go to GAC. Go to your working directory on the file system, move to \bin\Debug folder e.g.</p>
<p>C:\Work\EventHandler.SharePoint.SendEmail.Feature\EventHandler.SharePoint.SendEmail.Feature\<br />
bin\Debug</p>
<p>Here you will find your assembly i.e. EventHandler.SharePoint.SendEmail.Feature.dll</p>
<p>Open GAC i.e. c:\windows\assembly and drag and drop your dll in the GAC as shown below:<br /></br><br /></br></p>
<p style="text-align:center;"><img class="size-full wp-image-343 aligncenter" title="GAC" src="http://rehmangul.files.wordpress.com/2009/11/gac1.jpg?w=382&#038;h=488" alt="GAC" width="382" height="488" /></p>
<p></br><br /></br></p>
<p>Do an IISRESET.</p>
<p><strong>Create the Feature:</strong></p>
<p>Now comes the second part of our project i.e. to create the Feature. Remember, we have created a Feature Receiver until now, Feature itself is still to be created.</p>
<p>All Features in SharePoint lies in 12 hive under Features directory:</p>
<p>C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\TEMPLATE\FEATURES</p>
<p>Browse through a few Feature directories and you will find that all of them have a feature.xml file&#8230;&#8230;and some will also have an elements.xml.</p>
<p>Lets create a Feature of our own. Create a folder under Features directory and name it EventHandler.SharePoint.SendEmail.Feature&#8230;&#8230;&#8230;..could be any name..<br /></br><br /></br></p>
<p style="text-align:center;"><a href="http://rehmangul.files.wordpress.com/2009/11/feature-folder.jpg"><img class="size-full wp-image-355 aligncenter" title="Feature folder" src="http://rehmangul.files.wordpress.com/2009/11/feature-folder.jpg?w=505&#038;h=228" alt="" width="505" height="228" /></a></p>
<p></br><br /></br></p>
<p>Go inside the folder, right click -&gt; New -&gt; Text Document and rename the text document as feature.xml file. Create another file in the same manner and save it as elements.xml:<br /></br><br /></br></p>
<p style="text-align:center;"><img class="size-full wp-image-344 aligncenter" title="feature start" src="http://rehmangul.files.wordpress.com/2009/11/feature-start.jpg?w=550&#038;h=345" alt="feature start" width="550" height="345" /></p>
<p></br><br /></br></p>
<p>Right click feature.xml file and Open With -&gt; Notepad. Paste the following xml in the file and save:</p>
<p><code><br />
&lt;?xml version="1.0" encoding="utf-8"?&gt;<br />
&lt;Feature  Id="F2F6FE98-7A4C-4db7-B1E3-BC9C6E5CC9D7"<br />
          Title="EventHandler SharePoint SendEmail Feature"<br />
          Description="Email Alerts for AlertMe Library"<br />
          Version="1.0.0.0"<br />
          Hidden="FALSE"<br />
          Scope="Web"<br />
          DefaultResourceFile="core"<br />
          ReceiverAssembly="EventHandler.SharePoint.SendEmail.Feature, Version=1.0.0.0, Culture=neutral, PublicKeyToken=74b4a55dc039bd07"<br />
          ReceiverClass="EventHandler.SharePoint.SendEmail.Feature.EmailAlertsFeatureInstaller"<br />
          xmlns="<a href="http://schemas.microsoft.com/sharepoint/">http://schemas.microsoft.com/sharepoint/</a>"&gt;<br />
  &lt;ElementManifests&gt;<br />
    &lt;ElementManifest Location="elements.xml"/&gt;<br />
  &lt;/ElementManifests&gt;<br />
&lt;/Feature&gt;<br />
</code></p>
<p>Note that you have to be careful about four items in this xml. Feature Id, ReceiverAssembly, PublicKeyToken and ReceiverClass. They could be different in your case, so use the ones that you have.</p>
<p>For PublikKeyToken, go to GAC, take properties of your assembly and copy/paste into your feature.xml.</p>
<p>Feature Id is just a GUID. Here is how you can get one of your own:</p>
<p>Go to Visual Studio, click Tools -&gt;Create GUID. If Create GUID option is greyed out, click Tools -&gt; External Tools. Make the following settings as shown in the figure below and click OK. This will enable Create GUID option.</p>
<p>&#8220;Initial directory&#8221; in VS 2008 will be<br />
C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\Tools\<br /></br><br /></br></p>
<p style="text-align:center;"><img class="size-full wp-image-345 aligncenter" title="generate GUID" src="http://rehmangul.files.wordpress.com/2009/11/generate-guid.jpg?w=481&#038;h=427" alt="generate GUID" width="481" height="427" /></p>
<p></br><br /></br></p>
<p>Click Create GUID and you will receive it as under:<br /></br><br /></br></p>
<p style="text-align:center;"><a href="http://rehmangul.files.wordpress.com/2009/11/guid-shown.jpg"><img class="size-full wp-image-356 aligncenter" title="GUID shown" src="http://rehmangul.files.wordpress.com/2009/11/guid-shown.jpg?w=379&#038;h=337" alt="" width="379" height="337" /></a></p>
<p></br><br /></br></p>
<p>Click copy and paste it into Feature Id in feature.xml as shown above.</p>
<p>Open elements.xml and paste the following xml into it:</p>
<p><code><br />
&lt;?xml version="1.0" encoding="utf-8" ?&gt;<br />
&lt;Elements xmlns="<a href="http://schemas.microsoft.com/sharepoint/">http://schemas.microsoft.com/sharepoint/</a>"&gt;<br />
&lt;/Elements&gt;<br />
</code></p>
<p><strong>Install and Activate the Feature:</strong></p>
<p>Alright, coool, our feature is ready to be installed now.</p>
<p>Open the command prompt and move to the Features directory. Enter the following command:<br />
<code><br />
stsadm -o installfeature -name EventHandler.SharePoint.SendEmail.Feature<br />
</code></p>
<p></br><br /></br></p>
<p style="text-align:center;"><img class="size-full wp-image-346 aligncenter" title="feature install scr" src="http://rehmangul.files.wordpress.com/2009/11/feature-install-scr.jpg?w=600&#038;h=292" alt="feature install scr" width="600" height="292" /></p>
<p></br><br /></br></p>
<p>After you have received the &#8220;Operation completed successfully&#8221; message, navigate to your site in SharePoint. In my case the heirarchy was JumpStart -&gt; JumpStartWeb -&gt; AlertMe.</p>
<p>So, I&#8217;ll move to JumpStartWeb -&gt; Site Actions -&gt; Site Settings -&gt;  under Site Administration click Site Features. You will see your feature available there as shown below:.<br /></br><br /></br></p>
<p style="text-align:center;"><a href="http://rehmangul.files.wordpress.com/2009/11/feature-display-scr-11.jpg"><img class="size-full wp-image-357 aligncenter" title="feature display scr 1" src="http://rehmangul.files.wordpress.com/2009/11/feature-display-scr-11.jpg?w=439&#038;h=226" alt="" width="439" height="226" /></a></p>
<p></br><br /></br></p>
<p>Click Activate button in front of your feature to Activate the feature:<br /></br><br /></br></p>
<p style="text-align:center;"><img class="size-full wp-image-349 aligncenter" title="feature scr activate" src="http://rehmangul.files.wordpress.com/2009/11/feature-scr-activate.jpg?w=391&#038;h=141" alt="feature scr activate" width="391" height="141" /></p>
<p></br><br /></br></p>
<p><strong>Test your Event Handler:</strong></p>
<p>Go to your document library, in my case it is AlertMe and upload a document:<br /></br><br /></br></p>
<p style="text-align:center;"><a href="http://rehmangul.files.wordpress.com/2009/11/alertme-view.jpg"><img class="size-full wp-image-358 aligncenter" title="AlertMe view" src="http://rehmangul.files.wordpress.com/2009/11/alertme-view.jpg?w=516&#038;h=360" alt="" width="516" height="360" /></a></p>
<p></br><br /></br></p>
<p>As soon as you upload the file, you should receive an email to the address specified in your event handler:<br /></br><br /></br></p>
<p style="text-align:center;"><a href="http://rehmangul.files.wordpress.com/2009/11/email-itself1.jpg"><img class="aligncenter" title="Email itself" src="http://rehmangul.files.wordpress.com/2009/11/email-itself1.jpg?w=530&#038;h=296" alt="" width="530" height="296" /></a></p>
<p></br><br /></br></p>
<p>Hope this helps&#8211;<br /></br><br /></br></p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/rehmangul.wordpress.com/319/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/rehmangul.wordpress.com/319/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/rehmangul.wordpress.com/319/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/rehmangul.wordpress.com/319/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/rehmangul.wordpress.com/319/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/rehmangul.wordpress.com/319/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/rehmangul.wordpress.com/319/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/rehmangul.wordpress.com/319/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/rehmangul.wordpress.com/319/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/rehmangul.wordpress.com/319/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=rehmangul.wordpress.com&blog=637369&post=319&subd=rehmangul&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://rehmangul.wordpress.com/2009/11/17/writing-event-handlers-and-deploying-using-features/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/91d0677ad58d84af0a601b52b33e250c?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">rehmangul</media:title>
		</media:content>

		<media:content url="http://rehmangul.files.wordpress.com/2009/11/homepage-show1.jpg" medium="image">
			<media:title type="html">homepage show</media:title>
		</media:content>

		<media:content url="http://rehmangul.files.wordpress.com/2009/11/create-proj-scr11.jpg" medium="image">
			<media:title type="html">create proj scr1</media:title>
		</media:content>

		<media:content url="http://rehmangul.files.wordpress.com/2009/11/enter-proj-name.jpg" medium="image">
			<media:title type="html">enter proj name</media:title>
		</media:content>

		<media:content url="http://rehmangul.files.wordpress.com/2009/11/add-reference-4-with-all-screen-changes.jpg" medium="image">
			<media:title type="html">add reference 4 with all screen changes</media:title>
		</media:content>

		<media:content url="http://rehmangul.files.wordpress.com/2009/11/rename-class.jpg" medium="image">
			<media:title type="html">rename class</media:title>
		</media:content>

		<media:content url="http://rehmangul.files.wordpress.com/2009/11/references.jpg" medium="image">
			<media:title type="html">references</media:title>
		</media:content>

		<media:content url="http://rehmangul.files.wordpress.com/2009/11/select-wss.jpg" medium="image">
			<media:title type="html">select WSS</media:title>
		</media:content>

		<media:content url="http://rehmangul.files.wordpress.com/2009/11/obj-browser.jpg" medium="image">
			<media:title type="html">obj browser</media:title>
		</media:content>

		<media:content url="http://rehmangul.files.wordpress.com/2009/11/methods-auto-appear.jpg" medium="image">
			<media:title type="html">methods auto appear</media:title>
		</media:content>

		<media:content url="http://rehmangul.files.wordpress.com/2009/11/auto-para-and-base-call.jpg" medium="image">
			<media:title type="html">auto para and base call</media:title>
		</media:content>

		<media:content url="http://rehmangul.files.wordpress.com/2009/11/add-new-class.jpg" medium="image">
			<media:title type="html">add new class</media:title>
		</media:content>

		<media:content url="http://rehmangul.files.wordpress.com/2009/11/feature-installer-add-scr1.jpg" medium="image">
			<media:title type="html">feature installer add scr</media:title>
		</media:content>

		<media:content url="http://rehmangul.files.wordpress.com/2009/11/new-class-with-intelli-and-func.jpg" medium="image">
			<media:title type="html">new class with intelli and func</media:title>
		</media:content>

		<media:content url="http://rehmangul.files.wordpress.com/2009/11/sign-1.jpg" medium="image">
			<media:title type="html">sign 1</media:title>
		</media:content>

		<media:content url="http://rehmangul.files.wordpress.com/2009/11/sign-2.jpg" medium="image">
			<media:title type="html">sign 2</media:title>
		</media:content>

		<media:content url="http://rehmangul.files.wordpress.com/2009/11/key-code.jpg" medium="image">
			<media:title type="html">key code</media:title>
		</media:content>

		<media:content url="http://rehmangul.files.wordpress.com/2009/11/gac1.jpg" medium="image">
			<media:title type="html">GAC</media:title>
		</media:content>

		<media:content url="http://rehmangul.files.wordpress.com/2009/11/feature-folder.jpg" medium="image">
			<media:title type="html">Feature folder</media:title>
		</media:content>

		<media:content url="http://rehmangul.files.wordpress.com/2009/11/feature-start.jpg" medium="image">
			<media:title type="html">feature start</media:title>
		</media:content>

		<media:content url="http://rehmangul.files.wordpress.com/2009/11/generate-guid.jpg" medium="image">
			<media:title type="html">generate GUID</media:title>
		</media:content>

		<media:content url="http://rehmangul.files.wordpress.com/2009/11/guid-shown.jpg" medium="image">
			<media:title type="html">GUID shown</media:title>
		</media:content>

		<media:content url="http://rehmangul.files.wordpress.com/2009/11/feature-install-scr.jpg" medium="image">
			<media:title type="html">feature install scr</media:title>
		</media:content>

		<media:content url="http://rehmangul.files.wordpress.com/2009/11/feature-display-scr-11.jpg" medium="image">
			<media:title type="html">feature display scr 1</media:title>
		</media:content>

		<media:content url="http://rehmangul.files.wordpress.com/2009/11/feature-scr-activate.jpg" medium="image">
			<media:title type="html">feature scr activate</media:title>
		</media:content>

		<media:content url="http://rehmangul.files.wordpress.com/2009/11/alertme-view.jpg" medium="image">
			<media:title type="html">AlertMe view</media:title>
		</media:content>

		<media:content url="http://rehmangul.files.wordpress.com/2009/11/email-itself1.jpg" medium="image">
			<media:title type="html">Email itself</media:title>
		</media:content>
	</item>
		<item>
		<title>Send email to a user, getting it from a &#8216;Person or Group&#8217; field in a List</title>
		<link>http://rehmangul.wordpress.com/2009/11/10/send-email-to-a-user-getting-it-from-a-person-or-group-field/</link>
		<comments>http://rehmangul.wordpress.com/2009/11/10/send-email-to-a-user-getting-it-from-a-person-or-group-field/#comments</comments>
		<pubDate>Tue, 10 Nov 2009 23:58:59 +0000</pubDate>
		<dc:creator>rehmangul</dc:creator>
				<category><![CDATA[Blogroll]]></category>
		<category><![CDATA[MOSS]]></category>
		<category><![CDATA[MS SharePoint Sever]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[event handlers]]></category>
		<category><![CDATA[sharepoint]]></category>
		<category><![CDATA[sps]]></category>
		<category><![CDATA[Coding SharePoint]]></category>
		<category><![CDATA[Custom Sharepoint]]></category>
		<category><![CDATA[customise]]></category>
		<category><![CDATA[email server]]></category>
		<category><![CDATA[moss customisation]]></category>
		<category><![CDATA[SharePoint Customization]]></category>

		<guid isPermaLink="false">http://rehmangul.wordpress.com/?p=303</guid>
		<description><![CDATA[First, we have to read from &#8220;Person or Group&#8221; field.
It could be a &#8220;Person or Group&#8221; field that allows one user to be selected.
It could be a &#8220;Person or Group&#8221; field that allows multiple users to be selected.
If its a single user, get user, get his email address, send him email.
If there are multiple users, get each [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=rehmangul.wordpress.com&blog=637369&post=303&subd=rehmangul&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>First, we have to read from &#8220;Person or Group&#8221; field.<br />
It could be a &#8220;Person or Group&#8221; field that allows one user to be selected.<br />
It could be a &#8220;Person or Group&#8221; field that allows multiple users to be selected.<br />
If its a single user, get user, get his email address, send him email.<br />
If there are multiple users, get each of them one by one, get their email addresses, send them emails.</p>
<p>Do not copy/paste the code; and if you do, look for the typos <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> ; should be mostly alright though&#8230;.<br />
and also be careful coz inverted commas sometimes doesn&#8217;t get copied propertly from a web page&#8230;.</p>
<p><code></p>
<p>using Microsoft.SharePoint.Utilities;   //this one is for sending emails..</p>
<p>using (SPSite mySite = new SPSite("<a href="http://server/sites/site">http://server/site</a>"))<br />
{<br />
   using(SPWeb myWeb = mySite.OpenWeb())<br />
   {<br />
        SPList myList = myWeb.Lists["myListNameHere"];<br />
        SPFieldCollection allMyListFields = myList.Fields;</p>
<p>foreach(SPListItem myItem in myList.Items)  //go through all the items<br />
{<br />
         foreach (SPField myField in allMyListFields)  //go through all the fields<br />
         {<br />
                 if (myField.GetType() == typeof(SPFieldUser))  //check if the field is Person or Group field i.e. SPFieldUser<br />
                {          <br />
                          Type fieldType = myField.GetFieldValue(myItem[myField].ToString()).GetType();<br />
                            <br />
                           if (fieldType == typeof(SPFieldUserValueCollection))  //check if the field allows multiple selection of users                <br />
                          {<br />
                                string emailToFieldValues = myItem[myField].ToString();<br />
                                SPFieldUserValueCollection emailToUsers = new SPFieldUserValueCollection(myItem.Web, emailToFieldValues.ToString());<br />
                                foreach (SPFieldUserValue emailUser in emailToUsers)<br />
                                {<br />
                                    SPUser emailThisUser = emailUser.User;<br />
                                    string emailAddress = emailThisUser.Email.ToString();<br />
                                    SPUtility.SendEmail(myWeb, true, true, emailAddress, emailSubject, emailBody);<br />
                                }<br />
                            }<br />
                            else<br />
                            {<br />
                             SPFieldUserValue emailToFieldValue = (SPFieldUserValue)myField.GetFieldValue(myItem[myField].ToString());<br />
                                SPUser emailToUser = emailToFieldValue.User;<br />
                                string emailToAddress = emailToUser.Email.ToString();<br />
                                SPUtility.SendEmail(myWeb, true, true, emailToAddress, emailSubject, emailBody);<br />
                            } <br />
                        } //if1<br />
                     } //foreach2<br />
                   } //foreach1<br />
                 } //SPWeb<br />
               } //SPSite</p>
<p></code></p>
<p>So the quesiton is where can you put this code? Could be an event handler that sends an email to a user when an item is added to a document library. How to do that, look here:</p>
<p>http://rehmangul.wordpress.com/2009/11/17/writing-event-handlers-and-deploying-using-features/</p>
<p>Hope this helps&#8211;</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/rehmangul.wordpress.com/303/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/rehmangul.wordpress.com/303/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/rehmangul.wordpress.com/303/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/rehmangul.wordpress.com/303/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/rehmangul.wordpress.com/303/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/rehmangul.wordpress.com/303/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/rehmangul.wordpress.com/303/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/rehmangul.wordpress.com/303/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/rehmangul.wordpress.com/303/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/rehmangul.wordpress.com/303/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=rehmangul.wordpress.com&blog=637369&post=303&subd=rehmangul&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://rehmangul.wordpress.com/2009/11/10/send-email-to-a-user-getting-it-from-a-person-or-group-field/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/91d0677ad58d84af0a601b52b33e250c?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">rehmangul</media:title>
		</media:content>
	</item>
		<item>
		<title>MVP Award</title>
		<link>http://rehmangul.wordpress.com/2009/07/03/mvp-award/</link>
		<comments>http://rehmangul.wordpress.com/2009/07/03/mvp-award/#comments</comments>
		<pubDate>Fri, 03 Jul 2009 20:57:07 +0000</pubDate>
		<dc:creator>rehmangul</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://rehmangul.wordpress.com/?p=301</guid>
		<description><![CDATA[I am happy to share the news that Microsoft has announced MVP [Most Valuable Professional] award for me for the third consecutive year&#8230;.
https://mvp.support.microsoft.com/profile/rehman
It&#8217;s been a gratifying experience&#8230;..
       <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=rehmangul.wordpress.com&blog=637369&post=301&subd=rehmangul&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>I am happy to share the news that Microsoft has announced MVP [Most Valuable Professional] award for me for the third consecutive year&#8230;.</p>
<p><a href="https://mvp.support.microsoft.com/profile/rehman">https://mvp.support.microsoft.com/profile/rehman</a></p>
<p>It&#8217;s been a gratifying experience&#8230;..</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/rehmangul.wordpress.com/301/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/rehmangul.wordpress.com/301/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/rehmangul.wordpress.com/301/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/rehmangul.wordpress.com/301/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/rehmangul.wordpress.com/301/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/rehmangul.wordpress.com/301/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/rehmangul.wordpress.com/301/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/rehmangul.wordpress.com/301/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/rehmangul.wordpress.com/301/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/rehmangul.wordpress.com/301/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=rehmangul.wordpress.com&blog=637369&post=301&subd=rehmangul&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://rehmangul.wordpress.com/2009/07/03/mvp-award/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/91d0677ad58d84af0a601b52b33e250c?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">rehmangul</media:title>
		</media:content>
	</item>
		<item>
		<title>Approaches to Backup and Restore a Sharepoint Farm</title>
		<link>http://rehmangul.wordpress.com/2009/04/29/some-basic-information-to-backup-and-restore-a-sharepoint-farm/</link>
		<comments>http://rehmangul.wordpress.com/2009/04/29/some-basic-information-to-backup-and-restore-a-sharepoint-farm/#comments</comments>
		<pubDate>Wed, 29 Apr 2009 14:12:25 +0000</pubDate>
		<dc:creator>rehmangul</dc:creator>
				<category><![CDATA[Blogroll]]></category>
		<category><![CDATA[MOSS]]></category>
		<category><![CDATA[MS SharePoint Sever]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[sharepoint]]></category>
		<category><![CDATA[sps]]></category>
		<category><![CDATA[central administration]]></category>
		<category><![CDATA[configuration wizard]]></category>
		<category><![CDATA[configuration wizard errors]]></category>
		<category><![CDATA[Custom Sharepoint]]></category>
		<category><![CDATA[customise]]></category>
		<category><![CDATA[errors]]></category>
		<category><![CDATA[fix]]></category>
		<category><![CDATA[integration]]></category>
		<category><![CDATA[moss customisation]]></category>
		<category><![CDATA[moss errors]]></category>
		<category><![CDATA[move from testing to production]]></category>
		<category><![CDATA[move to another farm]]></category>
		<category><![CDATA[Service Unavailable]]></category>
		<category><![CDATA[SharePoint Customization]]></category>
		<category><![CDATA[sharepoint errors]]></category>
		<category><![CDATA[sharepoint farm]]></category>
		<category><![CDATA[stsadm]]></category>
		<category><![CDATA[tips and tricks]]></category>
		<category><![CDATA[workarounds]]></category>

		<guid isPermaLink="false">http://rehmangul.wordpress.com/?p=268</guid>
		<description><![CDATA[It is important to understand the differences between MOVING, MIGRATING or UPGRADING a farm:
http://technet.microsoft.com/en-us/library/cc262370.aspx
I&#8217;ll slightly touch these at the bottom of this article. Mainly, I am going to discuss approaches how can you MOVE from one farm to another.
MOVING to another farm:
If you are moving from a test farm to a production farm, this  involves [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=rehmangul.wordpress.com&blog=637369&post=268&subd=rehmangul&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>It is important to understand the differences between <strong>MOVING</strong>, <strong>MIGRATING</strong> or <strong>UPGRADING</strong> a farm:</p>
<p><a href="http://technet.microsoft.com/en-us/library/cc262370.aspx">http://technet.microsoft.com/en-us/library/cc262370.aspx</a></p>
<p>I&#8217;ll slightly touch these at the bottom of this article. Mainly, I am going to discuss approaches how can you <strong>MOVE</strong> from one farm to another.</p>
<p><strong>MOVING</strong> to another farm:</p>
<p>If you are moving from a test farm to a production farm, this  involves MOVING a farm. You must have similar hardware (32-bit or 64-bit which ever) and you must have similar software (version of sharepoint, windows, all software updates) and you must have similar topology (server names, number of servers) on the farm you are MOVING to.</p>
<p>The reason is becasue the configuration database and the Central Admin database contain computer-specific information. For that reason, you can only move to a new farm if you can configure it to be exactly the same as your original farm. Configuration database will not work for a new environment where topology, server roles or software updates are different.</p>
<p>Okey, if you do not have the same hardware, software or topology, then what to do? Then you should move everything in the farm except Configuration and Central Admin databases, and configure the new farm on your own, wihout expecting this to be done by the restore procedure, since we are not restoring configuration database. OR, you should consider <strong>MIGRATING</strong> or <strong>UPGRADING</strong>:</p>
<p><a href="http://technet.microsoft.com/en-us/library/cc262370.aspx">http://technet.microsoft.com/en-us/library/cc262370.aspx</a></p>
<p>So, let talk about <strong>MOVING</strong> to another farm. Microsoft says this is the way to &#8220;Move to another farm&#8221;:</p>
<p><a href="http://technet.microsoft.com/en-us/library/cc261918.aspx">http://technet.microsoft.com/en-us/library/cc261918.aspx</a></p>
<p>This page has a lot of information, hidden and obvious, I wish to consolidate it here:</p>
<p>There are three possible ways through which you can Backup and Restore your farm (note that I said backup/restore, not move):</p>
<ol>
<li>STSADM</li>
<li>Central Admin</li>
<li>Sql Server (lets ignore DPM and the others for the time being)</li>
</ol>
<p>But there is only one way to <strong>MOVE</strong> your farm to another farm and that is:</p>
<ul>
<li>Sql Server (tools)</li>
</ul>
<p><strong>MIGRATING</strong> to another farm using STSADM and Central Admin (tools) is regarded as obsolete. That means if you are moving to a new or different farm, you should not use Central Admin or STSADM command. So, moving or migrating whatever you may want to call it (because here it just means moving to a different environment), STSADM and Central Admin approach is obsolete. (I couldn&#8217;t find anywhere where Microsoft supports/permits you to <strong>MOVE</strong> to another/different/new farm using STSADM or Central Admin). </p>
<p><a href="http://technet.microsoft.com/en-us/library/cc262281.aspx">http://technet.microsoft.com/en-us/library/cc262281.aspx</a> (Migrating through Central Admin (Obsolete))</p>
<p><a href="http://technet.microsoft.com/en-us/library/cc263236.aspx">http://technet.microsoft.com/en-us/library/cc263236.aspx</a> (Migrating through STSADM (Obsolete))</p>
<p>We can restore our farm using STSADM and Central Admin, only on the <strong>SAME</strong> farm from which the backup was taken i.e. no new farm is involved at all:</p>
<p><a href="http://technet.microsoft.com/en-us/library/cc261704.aspx">http://technet.microsoft.com/en-us/library/cc261704.aspx</a> (Restore using STSADM)</p>
<p><a href="http://technet.microsoft.com/en-us/library/cc262928.aspx">http://technet.microsoft.com/en-us/library/cc262928.aspx</a> (Restore using Central Admin)</p>
<p>If you will use Central Admin, you will select &#8220;Same Configuration&#8221; option for the &#8220;Type of Restore&#8221; radio button. And for STSADM, you will use &#8220;overwrite&#8221; value for &#8220;-restoremethod&#8221; parameter. Using Central Admin, you can take farm level backup but it will not let you restore Central Admin and Configuration databases saying that &#8220;Central Admin and Configuration databases cannot be restored from this user interface&#8221;.</p>
<p> Now the only way left while <strong>moving</strong> to a new farm is SQL Server (tools):</p>
<p><a href="http://technet.microsoft.com/en-us/library/cc261918.aspx">http://technet.microsoft.com/en-us/library/cc261918.aspx</a></p>
<p>After we have reached this decision, remember that there could be two possibilites:</p>
<ol>
<li>Your new farm on which you are restoring may have different specs from the farm from which the backup is taken from. Specs means server names, software updates, number of servers.</li>
<li>Your new farm may have exactly the same specs as the farm from which the backup is taken from.</li>
</ol>
<p>If you plan to move Config and Central Admin databases, your new farm <strong>MUST </strong>have the same specs. If your new farm has different specs, then you should not move Config and Central Admin databases.</p>
<p>&#8220;Move to another farm&#8221; (<a href="http://technet.microsoft.com/en-us/library/cc261918.aspx">http://technet.microsoft.com/en-us/library/cc261918.aspx</a>) provides a step by step procedure to move to a new farm, and it assumes that sharepoint is already installed on the destination farm, which essentially means that Configuration and Central Admin databases are already created. So, if you have the same specs for your new farm, you can go ahead and overwrite Config and Central Admin databases, this will restore the configuration from the backup set.</p>
<p>Now it could be the case that you can live without moving Configuration and Central Admin databases to the new farm i.e. you will configure the new farm by yourself and you dont need to transfer Config and Central Admin databases from your old farm. So, what will you move then:</p>
<ol>
<li>Content Databases</li>
<li>SSP Databases</li>
<li>Search Databases for SSPs</li>
<li>Search Databases</li>
</ol>
<p>However, above databases can also be restored using Central Admin and STSADM approaches.</p>
<p>Summary: Moving to a new farm involves SQL Server and a farm with similar specs, otherwise do not move Config and Central Admin databases.</p>
<p>If you are looking to Move only the Content Databases, here is the one stop shop:</p>
<p><a href="http://technet.microsoft.com/en-us/library/cc262792.aspx">http://technet.microsoft.com/en-us/library/cc262792.aspx</a></p>
<p><strong>MIGRATING</strong> to another farm:</p>
<p>If you are changing from 32-bit hardware to 64-bit hardware, this will also be a MIGRATION process (i.e. change in hardware specs as mentioned earlier). If you are planning to change your existing SharePoint Server 2007 platform to Windows Server 2008 (platform), you might have to change to 64-bit hardware. And to upgrade Microsoft Office SharePoint Server 2007 to a 64-bit environment, you must migrate existing servers to a new farm. You cannot upgrade Office SharePoint Server 2007 directly from the 32-bit edition of Office SharePoint Server 2007 to the 64-bit edition.</p>
<p><a href="http://technet.microsoft.com/en-us/library/dd622865.aspx">http://technet.microsoft.com/en-us/library/dd622865.aspx</a></p>
<p><strong>UPGRADING</strong> a farm:</p>
<p> Upgrade is when you are moving to a different version of SharePoint Server e.g. from SharePoint 2003 to SharePoint 2007.</p>
<p> If you are moving just the database server (all databases including Config and Central Admin) and not the whole farm, look here:</p>
<p><a href="http://technet.microsoft.com/en-us/library/cc512725.aspx#Section1">http://technet.microsoft.com/en-us/library/cc512725.aspx#Section1</a></p>
<p>If you wish to <em>ditch</em> the farm level backup/restore and just move your website (site collection) to the new farm (and save yourself a lot of hassle), have a look here:</p>
<p><a href="http://rehmangul.wordpress.com/2009/04/18/sharepoint-site-backup-and-restore/">http://rehmangul.wordpress.com/2009/04/18/sharepoint-site-backup-and-restore/</a></p>
<p>After release of SP2 and CU for April, you can safely backup and restore your site collections to a new farm, without worrying about absolute URL issues:</p>
<p><a href="http://blogs.technet.com/stefan_gossner/archive/2009/05/01/red-is-green-up-is-down-and-the-unsupported-suddenly-becomes-supported.aspx">http://blogs.technet.com/stefan_gossner/archive/2009/05/01/red-is-green-up-is-down-and-the-unsupported-suddenly-becomes-supported.aspx</a></p>
<p>Hope this helps&#8230;.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/rehmangul.wordpress.com/268/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/rehmangul.wordpress.com/268/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/rehmangul.wordpress.com/268/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/rehmangul.wordpress.com/268/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/rehmangul.wordpress.com/268/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/rehmangul.wordpress.com/268/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/rehmangul.wordpress.com/268/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/rehmangul.wordpress.com/268/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/rehmangul.wordpress.com/268/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/rehmangul.wordpress.com/268/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=rehmangul.wordpress.com&blog=637369&post=268&subd=rehmangul&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://rehmangul.wordpress.com/2009/04/29/some-basic-information-to-backup-and-restore-a-sharepoint-farm/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/91d0677ad58d84af0a601b52b33e250c?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">rehmangul</media:title>
		</media:content>
	</item>
	</channel>
</rss>