If you have multiple send to connections to create or prefer to automate the deployment tasks related to your SharePoint environment, the following bit of code will help you create them automatically using the SPOfficialFileHost collection of your current site’s web application:

using (SPSite site = new SPSite("http://sp/"))
{
    SPWebApplication webapp = site.WebApplication;
    SPOfficialFileHost newhost = new SPOfficialFileHost(true);
    newhost.OfficialFileUrl = new Uri(site.Url+"/records/_vti_bin/officialfile.asmx");
    newhost.OfficialFileName = "Records Center";
    newhost.ShowOnSendToMenu = true;
    newhost.Action = SPOfficialFileAction.Move;
    webapp.OfficialFileHosts.Add(newhost);

    webapp.Update();
}

The options for the action are the following:

  • You can move the document from one location to another
    SPOfficialFileAction.Move;
  • You can create a copy of the document and send it to another location
    SPOfficialFileAction.Copy;
  • Or you can move the document but leave a link of its new location in its former location
    SPOfficialFileAction.Link;