Help with Cancelling meetings via VBScript.
I am trying to send cancellation notices to people in meetings. However, I get just accept, decliine, etc, not getting remove from calendar. What am I missing? const adModeReadWrite = 3Const adLockOptimistic = 3Const adFailIfNotExists = -1Const adOpenSource = &H00800000Const adOpenUnspecified = &Hffffffff DIM starttimeZ,endtimeZinboxURL = "http://ExchangeServer/exchange/ttest/calendar/" Set imsg = createObject("CDO.Message")set m_xmlHTTP =CreateObject("Microsoft.xmlhttp") Set oCn = createobject("ADODB.Connection")Set oRs = createobject("ADODB.RecordSet") oCn.Provider = "exoledb.datasource"oCn.Open inboxURL, "", "", -1 strSql = "" strSql = "select" strSql = strSql & " ""urn:schemas:mailheader:content-class"" " strSql = strSql & ", ""DAV:href"" " strSql = strSql & ", ""DAV:displayname"" " strSql = strSql & ", ""DAV:id"" " strSql = strSql & ", ""DAV:uid"" " strSql = strSql & ", ""urn:schemas:httpmail:subject"" " strSql = strSql & ", ""mail:htmldescription"" " strSql = strSql & ", ""urn:schemas:calendar:dtstart"" as startdate " strSql = strSql & ", ""urn:schemas:calendar:dtend"" as enddate " strSql = strSql & ", ""urn:schemas:calendar:busystatus"" " strSql = strSql & ", ""urn:schemas:calendar:alldayevent"" " strSql = strSql & ", ""urn:schemas:calendar:meetingstatus"" " strSql = strSql & ", ""urn:schemas:calendar:responserequested"" " strSql = strSql & ", ""urn:schemas:calendar:instancetype"" " strSql = strSql & ", ""urn:schemas:calendar:uid"" " strSql = strSql & ", ""urn:schemas:mailheader:to"" " strSql = strSql & ", ""urn:schemas:mailheader:cc"" " strSql = strSql & ", ""urn:schemas:mailheader:bcc"" " strSql = strSql & ", ""urn:schemas:httpmail:htmldescription"" " strSql = strSql & " from scope ('shallow traversal of """& inboxurl & """') " strSql = strSql & " WHERE ""DAV:ishidden"" = false" strSql = strSql & " AND ""DAV:isfolder"" = false" oRs.Open strSql, oCn, adOpenUnspecified, adLockOptimistic, 1 oRs.MoveFirst while not ORs.EOF on error goto 0 oField = oRs.Fields("DAV:href").value imsg.DataSource.Open ofield, oRs.ActiveConnection, admodeReadWrite, adfailIfNotExists,adOpenSource, "",""'--------START CANCEL PART if (cstr(oRs.Fields("urn:schemas:calendar:alldayevent").value)) = false then isallday = 0else isallday = 1end if Call setutctime (oRs.Fields("startdate").value,oRs.Fields("enddate").value) Set XMLreq = CreateObject("Microsoft.xmlhttp") XMLreq.open "PROPPATCH", ofield, False, "test", "password"xmlstr = "<?xml version=""1.0""?>" _ & "<g:propertyupdate "_ & " xmlns:g=""DAV:"" xmlns:e=""http://schemas.microsoft.com/exchange/"" "_ & " xmlns:mapi=""http://schemas.microsoft.com/mapi/"" "_ & " xmlns:mapit=""http://schemas.microsoft.com/mapi/proptag/"" "_ & " xmlns:x=""xml:"" xmlns:cal=""urn:schemas:calendar:"" "_ & " xmlns:dt=""urn:uuid:c2f41010-65b3-11d1-a29f-00aa00c14882/"" "_ & " xmlns:header=""urn:schemas:mailheader:"" "_ & " xmlns:mail=""urn:schemas:httpmail:""> "_ & " <g:set> "_&" <g:prop> "_ & " <g:contentclass>urn:content-classes:calendarmessage</g:contentclass> "_ & " <e:outlookmessageclass>Ipm.Schedule.Meeting.Canceled</e:outlookmessageclass> "_ & " <e:x-priority-long dt:dt=""int"">2</e:x-priority-long> "_ & " <mail:subject>Cancelled: "&oRs.Fields("urn:schemas:httpmail:subject").value&"</mail:subject> "_ & " <mail:htmldescription>Cancelled: "&oRs.Fields("urn:schemas:httpmail:subject").value&"</mail:htmldescription> "_ & " <cal:meetingstatus>CANCELLED</cal:meetingstatus> "_ & " <cal:dtend dt:dt=""dateTime.tz"">"&endtimeZ&"</cal:dtend> "_ & " <cal:dtstart dt:dt=""dateTime.tz"">"&starttimeZ&"</cal:dtstart> "_ & " <cal:alldayevent>"&isallday&"</cal:alldayevent> "_ & " <cal:busystatus>"&oRs.Fields("urn:schemas:calendar:busystatus").value&"</cal:busystatus> "_ & " <cal:method>CANCEL</cal:method> "_& " <cal:instancetype>"&oRs.Fields("urn:schemas:calendar:instancetype").value&"</cal:instancetype> "_ & " <cal:responserequested dt:dt=""boolean"">0</cal:responserequested> "_ & " <cal:removefromcalendar dt:dt=""boolean"">1</cal:removefromcalendar> "_ & " <cal:uid>"&oRs.Fields("urn:schemas:calendar:uid").value&"</cal:uid> "_ & " <header:cc>"&oRs.Fields("urn:schemas:mailheader:cc").value&"</header:cc> "_ & " <header:bcc>"&oRs.Fields("urn:schemas:mailheader:bcc").value&"</header:bcc> "_ & " <header:to>EMAILAddresses</header:to> "_ 'EMAILAddresses is figured out somehwere else, but this is not the problem since the messages are being sent& " <mapi:appstateflags>7</mapi:appstateflags> "_& " </g:prop> "_& " </g:set> "_ & " </g:propertyupdate> " XMLreq.setRequestHeader "Content-Type", "text/xml;" XMLreq.setRequestHeader "Translate", "f" XMLreq.setRequestHeader "Content-Length:", Len(xmlstr) XMLreq.send xmlstrIf (XMLreq.Status >= 200 And XMLreq.Status < 300) Then Wscript.echo "Success! " & "Results = " & XMLreq.Status & ": " & XMLreq.statusText ElseIf XMLreq.Status = 401 then Wscript.echo "You don't have permission to do the job! Please check your permissions on this item." Else Wscript.echo "Request Failed. Results = " & XMLreq.Status & ": " & XMLreq.statusText End If sDestinationURL = inboxurl & "/##DavMailSubmissionURI##/" sSource = ofield XMLreq.open "MOVE", sSource, False, "test", "password"xmlReq.setRequestHeader "Destination", sDestinationURL XMLreq.setRequestHeader "Content-Type", "message/rfc822;" XMLreq.setRequestHeader "Translate", "f" XMLreq.setRequestHeader "Content-Length:", Len(xmlstr) XMLreq.send xmlstr If (XMLreq.Status >= 200 And XMLreq.Status < 300) Then Wscript.echo "Success! " & "Results = " & XMLreq.Status & ": " & XMLreq.statusText ElseIf XMLreq.Status = 401 then Wscript.echo "You don't have permission to do the job! Please check your permissions on this item." Else Wscript.echo "Request Failed. Results = " & XMLreq.Status & ": " & XMLreq.statusText End If '--------END CANCEL PART oField = nullmsgid = nulloRs.MoveNextWend '########### SUBROUTINES ##################sub setutctime (starttime, endtime) syear = year(starttime)eyear = year(endtime) smonth = month(starttime)emonth = month(endtime)if smonth < 10 then smonth = 0 & smonthend ifif emonth < 10 then emonth = 0 & emonthend if sday = day(starttime)eday = day(endtime)if sday < 10 then sday = 0 & sdayend ifif eday < 10 then eday = 0 & edayend if stime = formatdatetime(starttime,4)etime = formatdatetime(endtime,4) starttimeT = syear & "-" & smonth & "-" & sday & "T"endtimeT = eyear & "-" & emonth & "-" & eday & "T"starttimeZ = starttimeT & stime & ":" & "00Z"endtimeZ = endtimeT & etime & ":" & "00Z" end sub
August 2nd, 2006 11:57pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics