Remove Method


Remove specified file from SessionFileCollection.

long Remove([in] BSTR Name)

Parameters

Name

Name of the file to be removed.

Return Value

Return value is zero if this method succeeds; otherwise return value is non-zero.

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" )
  WScript.Quit
End If

If SessionFiles.Remove( "testfile.dat" ) <> 0 Then
  WScript.Echo( "remove session file failed" )
End If