sp_OAMethod send does not work

  • I'm trying to create MS Exchange appointment via a trigger.

    The following ASP code is working A-oke:

    strApptURL = "http://" & strExchSvrName & "/exchange/test/Calendar/testappointment.eml"

    strApptRequest = " " & _

    "<g:propertyupdate " & strXMLNSInfo & _

    " " & _

    " " & _

    " " & _

    strMailInfo & _

    strCalInfo & _

    " " &_

    " " & _

    " " & _

    " "

    set xmlReq = CreateObject("Microsoft.XMLHTTP")

    xmlReq.open "PROPPATCH", strApptURL, False, strUserName, strPassword

    xmlReq.setRequestHeader "Content-Type", "text/xml"

    xmlReq.send strApptRequest

    set xmlReq = Nothing

    (of course the string variables are all set before this code)

    I tried to changed it into T-SQL:

    declare @ObjectID int

    Exec sp_OACreate 'Microsoft.XMLHTTP', @ObjectID OUT

    Exec sp_OAMethod @ObjectID, 'open', NULL, 'PROPPATCH', @strApptURL, false, @USERID, @PASSWORD

    Exec sp_OAMethod @ObjectID, 'setRequestHeader', NULL, 'Content-Length', 'text/xml'

    Exec sp_OAMethod @ObjectID, 'setRequestHeader', NULL, 'Depth', '0'

    Exec sp_OAMethod @ObjectID, 'send',@strApptRequest

    Exec sp_OADestroy @ObjectID

    This works UNTIL the 'send' line. Somehow i'm calling with incorrect parameters there:

    "ODSOLE Extended Procedure sp_OAMethod usage: ObjPointer int IN, MethodName varchar IN [, @returnval OUT [, additional IN, OUT, or BOTH params]]"

    It looks like i must do this:

    Exec sp_OAMethod @ObjectID, 'send'

    but how do i tell to send @strApptRequest???? or what am i missing on the send line?

  • it is not working yet.

    i found 1 bug: in the Content-Lenghth line i had 'text/xml'

    the following runs without errors, but unfortunately no appointment is created....

    Exec sp_OACreate 'MSXML2.ServerXMLHTTP.3.0', @ObjectID OUT

    Exec sp_OAMethod @ObjectID, 'open', NULL, 'PROPPATCH', @strApptURL, false, ' '

    Exec sp_OAMethod @ObjectID, 'setRequestHeader', NULL, 'Content-Type', 'text/xml'

    Exec sp_OAMethod @ObjectID, 'setRequestHeader', NULL, 'Content-Length', @ContentLength

    Exec sp_OAMethod @ObjectID, 'send',NULL,@strApptRequest

    Exec sp_OADestroy @ObjectID

    ideas, suggestions, etc are needed...

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply