Quite a few unusual elements in your code snippet, such as mixed use of NRTxx and IManxx object models, and explicit creation of a new session (you could just piggy-back on to the session available in the ICommand itself), however nothing that should stop your code from running.You don't describe what the symptoms are: are you getting any errors returned?
dim dms As ManDMSset dms = New ManDMS dim session As IManSessionSet session = dms.Sessions.Add("MyServerName")session.TrustedLoginDim db As IManDatabaseSet db = session.Databases.ItemByName("MyDatabaseName")dim dblist As ManStringsset dblist = New ManStringsdblist.Add db.Namedim params As IManFolderSearchParametersset params = dms.CreateFolderSearchParameters()params.Add imFolderName, "My Document Folder Name"dim folders As IManFoldersset folders = session.WorkArea.SearchFolders(dblist, params)dim targetFolder As IManFolderSet targetFolder = folders.ItemByIndex(1)dim doc As IManDocumentSet doc = db.GetDocument(12345, 1) ' doc number and versiondim contents As IManDocumentsset contents = targetFolder.Contentscontents.AddDocumentReference doc