Little Folder Name help in LS please

I’m trying to use the following script to create config.txt files in support of automating Lotus Notes client configurations. Specifically, I would like to use a field value for a subfolder name. For example:

c:\USERNAME\config.txt

Here is the code which is run from an action agent (selected docs):

Sub Initialize

Dim session As NotesSession

Dim db As NotesDatabase

Dim dc As NotesDocumentCollection

Dim doc As NotesDocument

Dim stream As NotesStream

Dim nam As NotesName

Dim pathname As String

Dim ADNetworkID As String



Set session = New NotesSession

Set db = session.CurrentDatabase

Set dc = db.UnprocessedDocuments

Set doc = dc.GetFirstDocument()

Set stream = session.CreateStream



While Not(doc Is Nothing)	

	'pathname = "c:\Configs\"		

	ADNetworkID = doc.GetItemValue("NetworkID")(0)

	Set nam = New NotesName(doc.GetItemValue("NotesID")(0))

	'pathname = Lcase$ ( "c:\Configs\" & firstinitial & doc.GetItemValue("LastName")(0) & "config.txt")	

	'pathname = Lcase$ ( "c:\Configs\" & ADNetworkID & "config.txt")

	pathname = Lcase$ ( "c:\" & doc.GetItemValue("NetworkID")(0) & "\" & "config.txt")

	If Not stream.Open(pathname, "ASCII") Then

		Messagebox pathname,, "Open failed"

		Exit Sub

	End If

	If stream.Bytes <> 0 Then

		Messagebox pathname,, _

		"File already exists and has content"

		Exit Sub

	End If

	'Call stream.WriteText(doc.GetItemValue("Certificate")(0), EOL_CRLF)

	Call stream.WriteText("UserName=" & nam.Abbreviated, EOL_CRLF)

	Call stream.WriteText("Keyfilename=H:\notes\data\" & ADNetworkID & ".id", EOL_CRLF)

	Call stream.WriteText("Domino.Name=DOMINOSERVERNAME/Domain", EOL_CRLF)

	Call stream.WriteText("Domino.Address=mailserver.domain.com", EOL_CRLF)

	Call stream.WriteText("Domino.Port=TCPIP", EOL_CRLF)

	Call stream.WriteText("Domino.Server=1", EOL_CRLF)

	Call stream.WriteText("AdditionalServices=0", EOL_CRLF)

	Call stream.WriteText("AdditionalService.NetworkDial=0", EOL_CRLF)

	Call stream.WriteText("Replication.Threshold=9999", EOL_CRLF)

	Call stream.WriteText("Replication.Schedule=0", EOL_CRLF)

	Call stream.Close

	Set doc = dc.GetNextDocument(doc)

Wend

End Sub

End of Code******************************************

The error message received is: “Open Failed”.

If I use the username value in the filename (ie: c:\usernameconfig.txt), the code works.

I presume it is because the filename is not ascii but don’t know how to make it so.

Your guidance is very much appreciated!

Subject: Little Folder Name help in LS please

I believe I found my answer. It appears the subfolder (username) needs to exist before the file is created.