Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
THRUST SERVICES & TOOLS
CLOUD EDITIONS
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Web CMS (TeamSite)
Email import
MalcolmPlains
1) I would like to use Outlook VBA to import outlook emails to FileSite using part of the subject line to determine the destination workspace.
2) I have written some Outlook VBA code to import a .msg file, and it goes into the database (full text search finds it), but I can not figure out how to tell it what the destination workspace should be.
Any suggestions would be appreciated.
Thanks.
Find more posts tagged with
Comments
MalcolmPlains
' Test proc to try and add a doc to the 'General' folder of the 'L7777'
' workspace. I will want to add docs to a folder in a worksapce based on
' a keyword in the filename. The document gets added to WorkSite,
' (I can see it if I do a full text search), but I can't figure out how to
' make it show up in a folder in the L7777 workspace.
Public Sub AddDoc()
OpenUp
Dim DocumentToImportStr As String: DocumentToImportStr = "c:\L7777 RE My Dentist.msg"
' Create the document object
Dim myDoc As IManDocument: Set myDoc = myDB.CreateDocument
' Declare and set required profile fields
Dim myAuthor As IManUser: Set myAuthor = myDB.GetUser("msmccorquodale")
myDoc.SetAttributeByID imProfileAuthor, myAuthor
Dim myOperator As IManUser: Set myOperator = myDB.GetUser("msmccorquodale")
myDoc.SetAttributeByID imProfileOperator, myOperator
' Set DocType to based on the document to import...
Dim myDocType As IManDocumentType
Set myDocType = myDB.GetDocumentTypeFromPath(DocumentToImportStr)
myDoc.SetAttributeByID imProfileType, myDocType
Dim myDocClass As IManDocumentClass
Set myDocClass = myDB.SearchDocumentClasses("E-MAIL", imSearchBoth, True).ItemByIndex(1) ' index is the alias.
myDoc.SetAttributeByID imProfileClass, myDocClass
' Set subclass if any
Dim myDocSubClass As IManDocumentClass
If myDocClass.SubClassRequired = True Then
Dim myDocSubClasses As IManDocumentClasses
Set myDocSubClasses = myDocClass.GetSubClasses("", imSearchBoth, True)
If myDocSubClasses.Count > 0 Then
Set myDocSubClass = myDocSubClasses.ItemByIndex(1)
myDoc.SetAttributeByID imProfileSubClass, myDocSubClass
End If
End If
myDoc.SetAttributeByID imProfileCustom1, "L"
myDoc.SetAttributeByID imProfileCustom2, "L7777"
myDoc.Description = "Test Doc Description"
myDoc.Comment = "Test Doc Comment"
Dim rc As IManCheckinResult
Set rc = myDoc.CheckInWithResults(DocumentToImportStr, imCheckinNewDocument, imDontKeepCheckedOut)
Dim myDocs As IManDocuments
If Not rc.Succeeded Then
Dim colProfileErrors As IManProfileErrors
Set colProfileErrors = rc.ErrorList
Dim myProfileError As IManProfileError
Dim strErrorMessage As String
strErrorMessage = ""
For Each myProfileError In colProfileErrors
strErrorMessage = "Reason: " & strErrorMessage & myProfileError.Description & " Attrib=" & myProfileError.AttribID & " ErrCode=" & myProfileError.ErrorCode & vbCrLf
Next
MsgBox rc.ErrorMessage & " Error Code:" & rc.ErrorCode & vbCrLf & strErrorMessage, vbOKOnly, "CheckIn Error"
End If
CleanUp
End Sub
'-----------------------------
Private Sub OpenUp()
' Connect to the database using trusted login
Set mySessions = myDMS.Sessions
mySessions.Add("PAAHOUINTWST").TrustedLogin
' Get this session
Set mySession = mySessions.ItemByName("PAAHOUINTWST")
' Set the preferred database
Set myDB = mySession.PreferredDatabase
End Sub
'-----------------------------
Private Sub CleanUp()
' Clean up
If mySession.Connected = True Then
mySession.Logout
myDMS.Close
End If
End Sub
jny
You would first need to get a hold of the destination folder either by calling the SearchFolders (WorkArea) Method or search for the workspace first, via SearchWorkspaces (Database), then get its DocumentFolders collection back and iterate through it. It all depends on the search input you have.
Once you have a handle to the destination folder object, you may then add a reference to the imported document to it, like so:
'Assuming docfldr is a valid handle to the destination folder.
Dim docfldr As IManage.IManDocumentFolder
Dim fldrDox As IManage.IManDocuments
fldrDox.AddDocumentReference(myDoc)
MalcolmPlains
Thanks, that was just the clue I needed.
I modified my code as follows:
...
Set rc = myDoc.CheckInWithResults(DocumentToImportStr, imCheckinNewDocument, imDontKeepCheckedOut)
If rc.Succeeded Then
Dim myDocs As IManage.IManDocuments
' Return the documents in the General folder of WS L7777.
Set myDocs = FindFolder("L7777%", "General").Contents
myDocs.AddDocumentReference rc.Result
Else
Dim colProfileErrors As IManProfileErrors
...