Tuesday, May 5, 2009

How to send document to record center programatically in MOSS 2007 ?

Here is the code to send document programatically in MOSS 2007. The below code can be used in console/win apps - but in the SharePoint box because of using SharePoint Object Libraries

private void SendDocumentToRecordsCenter()
{
try
{
string MoreInfo= string.Empty
OfficialFileResult Result;

SPSite mySite = new SPSite("http://ServerName");
SPWeb myWeb = mySite.OpenWeb();

SPFile myDoc = myWeb.GetFile("LibreryName/Doc1.docx");

Result =
myDoc.SendToOfficialFile(out MoreInfo);

Console.WriteLine("Result after execution: " + Result);
}
catch (Exception ex)
{
Console.WriteLine("Error - " + ex.ToString());
}
}

No comments: