Wednesday, February 15, 2012

Send to Connection using Code And Shell

New feature in SharePoint 2010 "Send To Connections" offers good support for managed Documents. A user can easily Move, Copy or send document to a new location.

Documents can be sent accross sites and even web application.
We can create Send To Connection in three ways.
  • Using Central Administration.
  • Using Code.
  • Using Power Shell.

Here I am not discussing about content organizer feature. I assume you know about "Content Organizer" feature.

Lets take an example to create "Send To Connection", source site is at url http://anmol-pc and your destination site is http://anmol-pc/Recordcenter/

First of all activate "Content Organizer" feature on both sites. Next step is create "Send To Connection". Below are three methods you can use any one you like.

How to create send to connection using Central Administration?

  • Go to Central Administration
  • General Application Settings 
  • "Configure send to connections" under heading "External Service Connections". This will open up a Send To Connection configuration page. 
  • Select checkbox "Allow sites to send to connections outside the site subscription" under Site Subscription Settings.
  • Under Connection give "Display Name" 
  • Send To Url, this is location of service on destination site. In our example it should be http://anmol-pc/Recordcenter/_vti_bin/officialfile.asmx 
  • Specify "Send To Action". Three options are available "Copy", "Move", "Move Leave a Link" 
  • Click Add Connection and click ok.

    Below is screenshot how it looks like.

How to create send to connection using Code?

using (SPSite site = new SPSite("http://anmol-pc"))
   SPOfficialFileHost officialFileHost = new SPOfficialFileHost(true);   
   officialFileHost.OfficialFileUrl = 

          new Uri(site.Url+"/recordcenter/_vti_bin/officialfile.asmx");   
   officialFileHost.OfficialFileName = "Records Center";   
   officialFileHost.ShowOnSendToMenu = true; 
   officialFileHost.Action = SPOfficialFileAction.Move;   

   SPWebApplication webapp = site.WebApplication;

How to create send to connection using shell?

$SiteUrl = "http://anmol-pc"
$RecordCenterUrl = "recordcenter"

$SPSite = Get-SPSite | Where-Object {$_.Url -eq $SiteUrl}
$officialFileHost = New-Object Microsoft.SharePoint.SPOfficialFileHost
$officialFileHost.OfficialFileName = "Records Center"
$SubmissionServiceUrl = $SiteUrl + "/" + $RecordCenterUrl + "/_vti_bin/officialfile.asmx"

$officialFileHost.OfficialFileUrl = $SubmissionServiceUrl
$officialFileHost.ShowOnSendToMenu = $true
$officialFileHost.Explanation = "Send a file to Records Center"


Write-Host "Send to Connection complete"

Popular Posts