Anyone know why I can’t create a folder using COM? I’ve tried several different ways of doing it and each one hangs the Notes client when I attempt to run my test code(I am the manager of the database). The code will succeed if the folder already exists. If I write the equivelant code in Lotus Script it works. Here’s the VB code:
Public Sub saveMessageToFolder(Recipients As Variant, messageContent As String)
On Error GoTo errorHandler
Dim dbDir As NotesDbDirectory
Dim AddressBook As NotesDatabase
Dim Maildb As NotesDatabase
Dim MailDoc As NotesDocument
Dim LocationDoc As NotesDocument
If Not IsArray(Recipients) Then
MsgBox "Parameter 'Recipients' in SUB sendMessage must be an array!", vbCritical, "Error"
Exit Sub
ElseIf messageContent = "" Then
MsgBox "Parameter 'messageContent' in SUB sendMessage must not be empty!", vbCritical, "Error"
End If
Set AddressBook = getLocalNAB()
Set LocationDoc = getLocationDocument(AddressBook)
If LocationDoc.GetItemValue("MailType")(0) = MAIL_LOCATION_LOCAL Then
Set dbDir = Session.GetDbDirectory("")
ElseIf LocationDoc.GetItemValue("MailType")(0) = MAIL_LOCATION_ON_SERVER Then
Set dbDir = Session.GetDbDirectory(LocationDoc.GetItemValue("MailServer")(0))
End If
Set Maildb = dbDir.OpenDatabase(LocationDoc.GetItemValue("MailFile")(0))
If Maildb Is Nothing Then
MsgBox "Could not open mail file"
Exit Sub
End If
Set MailDoc = Maildb.CreateDocument()
If MailDoc Is Nothing Then
MsgBox "Could not create mail document"
Exit Sub
End If
Call MailDoc.ReplaceItemValue("Form", "Memo")
Call MailDoc.ReplaceItemValue("SendTo", Recipients)
Call MailDoc.ReplaceItemValue("Subject", messageContent)
Call MailDoc.Send(False)
Call MailDoc.Save(True, False, True)
Call Maildb.EnableFolder(FOLDER_NAME)
Call MailDoc.PutInFolder(FOLDER_NAME)
'Call MailDoc.PutInFolder(FOLDER_NAME, True)
Exit Sub
errorHandler:
MsgBox Error$ + " (" + CStr(Err) + ") in saveMessageToFolder."
Exit Sub
End Sub