niedziela, 21 czerwca 2015

Create SendTo connection programmatically

private const string CONTENT_ORGANIZER_URL = "/_vti_bin/officialfile.asmx";

/// To run this code without Access Denied error, RemoteAdministratorAccessDenied must be set False. Do it with PowerShell:
/// $contentService = [Microsoft.SharePoint.Administration.SPWebService]::ContentService
/// $contentService.RemoteAdministratorAccessDenied = $false
/// $contentService.Update()
SPSecurity.RunWithElevatedPrivileges(delegate()
{
SPWebApplication webapp = newRC.WebApplication;
       var newhost = new SPOfficialFileHost(true);
       newhost.OfficialFileUrl = new Uri("url of site with content organizer feature on" + CONTENT_ORGANIZER_URL);
       newhost.OfficialFileName = "Your connection name";
       newhost.Explanation = "Your connection description";
       newhost.ShowOnSendToMenu = false;
       newhost.Action = SPOfficialFileAction.Move;
webapp.OfficialFileHosts.Add(newhost);
webapp.Update();
});


Brak komentarzy:

Prześlij komentarz