SessionFileCollection object


Methods

Add Add file to collection.
Remove Remove file from collection.
Clear Clear all files.

Properties

Items Get SessionFile.
Count Get total count of SessionFile in SessionFileCollection.

Remarks

SessionFileCollection can be used to add/remove temporary file in EAS. All files will be cleaned automatically after user logout or session expired. "system" user can't use SessionFileCollection/SessionFile object, other users must connect to server with session required to use SessionCollection/SessionFile object.

Usage Example

Dim server, user, password, requestAddr
server = "localhost"
user = "test@adminsystem.com"
password = "mypassword"
requestAddr = "192.168.0.1"

Const SessionRequired = 1
Dim oSvr
Set oSvr = CreateObject("EmailArchitectObjects.ServerRoot")
r = oSvr.Connect( server, user, password, SessionRequired, requestAddr )
If r <> 0 Then
  WScript.Echo( "connect server failed!" )
  WScript.Quit
End If

WScript.Echo( "current session key is " & oSvr.SessionKey )

Dim SessionFiles, SessionFile, Chunk
Set SessionFiles = oSvr.SessionFileCollection

'since vbscript doesn't support reading binary file,
'here we read file as text file and use Tools object to convert string
'to binary data.

Const ForReading = 1, ForWriting = 2
Dim fso, f, dataString

Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.OpenTextFile("c:\testfile.dat", ForRead, False )
dataString = f.ReadAll()
f.Close

Dim oTool
Set oTool = CreateObject("EmailArchitectObjects.Tools")
Chunk = oTool.BSTR2A( dataString, 0 )

Set SessionFile = SessionFiles.Add( "testfile.dat", Chunk )
If SessionFile Is Nothing Then
  WScript.Echo "add session file failed"
End If