Cannot checkin when call a web agent through URL

I write a web agent to create a new document and check in .It works well when running on server.But when I call the agent though the url.The document can be created ,yet cannot be checked in.

If I delete the statement “Call theNewDocument.SetContents(“H:\MyDoc.txt”)”,it works well no matter on sever or through URL.But I need to set certain attachment to the new document.How can I do this?

This is the code :

Sub Initialize

On Error Goto HandleError 

'Declare all API objects as Variants

Dim theApi As Variant

Dim theLibrary As Variant

Dim theCabinets As Variant

Dim theCabinet As Variant

Dim theBinder As Variant

Dim theDocuments As Variant

Dim theNewDocument As Variant



Dim theCategories As Variant

Dim theCategory As Variant

’ Call the Domino.Doc API

Set theApi = CreateObject("DominoDoc.API")

Call theApi.SetHttpLogin("shangp", "Thinkpad2008$")

Set theLibrary = theApi.GetLibrary("http://mkzsgt01.ap.infineon.com/domdoc/chinadevlib.nsf")



Set theCabinet = theLibrary.Cabinets("ChinaDev")

’ Get the Cabinet Categories properties

Set theCategories=theCabinet.Categories

Set theCategory=theCategories("Domino")



Set theBinders=theCategory.Binders

Set theBinder = theBinders("Read")

’ Create new document

Set theDocuments = theBinder.Documents

Set theNewDocument = theDocuments.Add



Call theNewDocument.SetContents("H:\MyDoc.txt")

theNewDocument.Title = "hehe1"

Call theNewDocument.Save

'Check In the Document as a new version

Call theNewDocument.CheckIn(1, 2, False, "Created by Syntony Agent")	





Exit Sub

HandleError:

Print "Error = "Error$ + "On line #= " + Str(Erl()) 

End Sub

Thanks in advance.