我正在尝试使用Outlook规则更新/插入SharePoint列表中的项目。我想做的是:
我在google搜索时找到了以下代码:
Dim objXMLHTTP As MSXML2.XMLHTTP
Dim strListNameOrGuid As String
Dim strBatchXml As String
Dim strSoapBody As String
Sub MoveHFtoSharePointRule(Item As Outlook.MailItem)
Set objXMLHTTP = New MSXML2.XMLHTTP
strListNameOrGuid = "Invoicing List"
'Add New Item'
strBatchXml = "<Batch OnError='Continue'><Method ID='3' Cmd='New'><Field Name='ID'>New</Field><Field Name=" + FieldNameVar + ">" + ValueVar + "</Field></Method></Batch>"
objXMLHTTP.Open "POST", SHAREPOINTURL + "_vti_bin/Lists.asmx", False
objXMLHTTP.setRequestHeader "Content-Type", "text/xml; charset=""UTF-8"""
objXMLHTTP.setRequestHeader "SOAPAction", "http://schemas.microsoft.com/sharepoint/soap/GetList"
strSoapBody = "<soap:Envelope xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' " _
& "xmlns:xsd='http://www.w3.org/2001/XMLSchema' " _
& "xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'><soap:Body><GetList " _
& "xmlns='http://schemas.microsoft.com/sharepoint/soap/'><listName>" & strListNameOrGuid _
& "</listName></GetList></soap:Body></soap:Envelope>"
MsgBox ("HERE")
objXMLHTTP.Send strSoapBody
If objXMLHTTP.Status = 200 Then
' Do something with response
MsgBox ("hello")
Else
MsgBox ("hi")
End If
Set objXMLHTTP = Nothing
End Sub
但是我在VB的声明部分添加Dim objXMLHTTP As MSXML2.XMLHTTP
的时间我的规则根本没有执行。
请帮助以最简单的方式执行此操作。