Add a file to SessionFileCollection object.
ISessionFile* Add( [in] BSTR Name, [in] VARIANT Chunk )
Parameters
Name
File name without path.
Chunk
Binary data of file.
Return Value
Return value is a SessionFile object if this method succeeds; otherwise return value is null.
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