Skip to main content

Updating appointments that are 1 hour out because of the Commonwealth Games Timezone Changes

Since i posted this last month I had a few questions around updating appointments that appear 1 hour out after you have updated the Timezone patch for the Commonwealth games. Firstly the only supported method of updating affected appointment is in http://www.microsoft.com/australia/timezone/2005.aspx which is to export the appointments in the overlap period to a text file, delete the appointments and then re-import those appointments.

One completely unsupported method to update appointments is to use CDOEX and Exoledb to move the appointment times one hour into the past for appointments that exists in the overlap period. One issue with using this method is that if you have any reoccurring appointments that have been expanded within the overlap period then changing the date and time on these instances of the recurring appointments will break the recursion on that instance of the expanded appointment so although outlook will show the appointment now occurs at the right time is will show the circle with the cross through it to indicate this appointment is an exception to the normal recurrence of the appointment. The other issue is that apart from myself this method hasn’t been really tested so there may be some other potential snags. But if you’re looking for something to test in a development environment to see if you can fix this problem this script could come in handy. The other problem is there has now been a patch released for home users that modifies the current timezone instead of adding a new time-zone. Its recommended that you don’t use this patch if you use Exchange or OWA and its quite possible that machines will have this patch applied and have created appointments that appear correct with the old timezone data. In this case running this script would actually make those appointments appear wrongly. You really need to be aware of how your machines have been patched before contemplating a fix.

The Script

Before you run the fix script I recommend you run a scan using another script I posted here. This will give you a list of all the appointments that are in the affected overlap period and which appointments will be modified by the script. The fix script queries for appointments within the overlap period that appear to be created from machines that haven’t had the patch applied or from OWA where the Timezone has been updated in the options. By looking at the urn:schemas:calendar:timezoneid property or the http://schemas.microsoft.com/mapi/id/{00062002-0000-0000-C000-000000000046}/0x8234 mapi property. The script then shifts the time of the appointment back one hour by adjusting the start and end times and updates the timezone information so that if the script is run again it wont modify the appointments for a second time.

Before using the script you need to update the domainname variable within the script to reflect the default SMTP domain name you are using eg

domainname = "domain.com"


The script uses Exoldb so it needs to be run from the server where the mailbox is located. The script is designed to be run on one mailbox at a time so to run the script you need to enter the mailbox you what to run it against as a commandline parameter eg cscript gapchangeex.vbs username. As stated before don’t run this script in production unless you have thoroughly tested it.

I’ve posted a copy of the script here the script itself looks like

user = wscript.arguments(0)
Set fso = CreateObject("Scripting.FileSystemObject")
fname = "c:\" & wscript.arguments(0) & ".csv"
set wfile = fso.opentextfile(fname,2,true)
wfile.writeline("User,Subject,UTC timestart,UTC timeend, InstanceType,
OutlookTimezone,CDOTimezoneEnumID")
public datefrom
public dateto
datefrom = "2006-03-26T10:00:00Z"
dateto = "2006-04-02T10:00:00Z"
domainname = "domain.com"
sConnString = "file://./backofficestorage/" & domainname
sConnString = sConnString & "/mbx/" & user & "/calendar"
call QueryCalendarFolder(sConnString,user)

wscript.echo "Done"


Public Sub QueryCalendarFolder(sConnString,user)
SSql = "SELECT ""DAV:href"", ""DAV:parentname"", ""urn:schemas:calendar:timezoneid"",
""urn:schemas:httpmail:subject"", "
SSql = SSql & """http://schemas.microsoft.com/mapi/id/{00062002-0000-0000-C000-000000000046}/0x8234"",
""urn:schemas:calendar:timezone"", "
SSql = SSql & """urn:schemas:calendar:instancetype"", ""urn:schemas:calendar:dtstart""
, ""urn:schemas:calendar:dtend"" "
SSql = SSql & "FROM scope('shallow traversal of """ & sConnString & """') "
SSql = SSql & " Where ""DAV:isfolder"" = false AND ""DAV:ishidden"" = false "

SSql = SSql & "AND ""urn:schemas:calendar:dtend"" > CAST(""" & datefrom & """ as
'dateTime') " _
& "AND ""urn:schemas:calendar:dtstart"" < CAST(""" & dateto & """ as 'dateTime')"

Set oConn = CreateObject("ADODB.Connection")
oConn.Provider = "Exoledb.DataSource"
oConn.Open sConnString
Set oRecSet = CreateObject("ADODB.Recordset")
oRecSet.CursorLocation = 3
oRecSet.Open sSQL, oConn.ConnectionString
if err.number <> 0 then wfile.writeline(user & "," & "Error Connection to
Mailbox")
While oRecSet.EOF <> True
select case oRecSet.fields("http://schemas.microsoft.com/mapi/id/{00062002-0000-0000-C000-000000000046}/0x8234").value
case "(GMT+10:00) Canberra, Melbourne, Sydney" susapt = 1
upto = "(GMT+10:00) Canberra, Melbourne, Sydney (Commonwealth Games)"
case "(GMT+09:30) Adelaide" susapt = 1
upto = "(GMT+09:30) Adelaide (Commonwealth Games)"
case "(GMT+10:00) Hobart" susapt = 1
upto = "(GMT+10:00) Hobart (Commonwealth Games)"
case "(GMT+10:00) Canberra, Melbourne, Sydney (Commonwealth Games)" susapt = 2
case "(GMT+09:30) Adelaide (Commonwealth Games)" susapt = 2
case "(GMT+10:00) Hobart (Commonwealth Games)" susapt = 2
end select
select case oRecSet.fields("urn:schemas:calendar:timezoneid").value
case "78" susapt = 2
case "79" susapt = 2
case "80" susapt = 2
case "57" susapt = 1
uptoid = "78"
case "19" susapt = 1
uptoid = "79"
case "42" susapt = 1
uptoid = "80"
end select
if susapt = 0 then
if instr(oRecSet.fields("urn:schemas:calendar:timezone").value,"TZID:GMT +0930")
then
susapt = 1
upto = "(GMT+09:30) Adelaide (Commonwealth Games)"
end if
if instr(oRecSet.fields("urn:schemas:calendar:timezone").value,"TZID:GMT +1000")
then
susapt = 1
upto = "(GMT+10:00) Canberra, Melbourne, Sydney (Commonwealth Games)"
end if

end if
if susapt = 1 then
Wscript.echo User
wscript.echo oRecSet.fields("DAV:Href").value
wscript.echo oRecSet.fields("urn:schemas:httpmail:subject").value
wscript.echo oRecSet.fields("http://schemas.microsoft.com/mapi/id/{00062002-0000-0000-C000-000000000046}/0x8234").value
wscript.echo oRecSet.fields("urn:schemas:calendar:timezoneid").value
wscript.echo oRecSet.fields("urn:schemas:calendar:instancetype").value
wscript.echo
wfile.writeline(user & "," &
oRecSet.fields("urn:schemas:httpmail:subject").value & ","_
& oRecSet.fields("urn:schemas:calendar:dtstart").value & "," &
oRecSet.fields("urn:schemas:calendar:dtend").value _
& "," & oRecSet.fields("urn:schemas:calendar:instancetype").value & "," _
& replace(replace(oRecSet.fields("http://schemas.microsoft.com/mapi/id/{00062002-0000-0000-C000-000000000046}/0x8234").value,vbcrlf,""),",","")
_
& "," & oRecSet.fields("urn:schemas:calendar:timezoneid").value)
set apptobj = createobject("ADODB.Record")
apptobj.open cstr(oRecSet.fields("DAV:HREF").value),,3
wscript.echo dateadd("h",-1,oRecSet.Fields("urn:schemas:calendar:dtstart").value)
apptobj.Fields("urn:schemas:calendar:dtstart").value = dateadd("h",-1,oRecSet.Fields("urn:schemas:calendar:dtstart").value)
apptobj.Fields("urn:schemas:calendar:dtend").value = dateadd("h",-1,oRecSet.Fields("urn:schemas:calendar:dtend").value)
if uptoid <> "" then apptobj.Fields("urn:schemas:calendar:timezoneid").value =
uptoid
if upto <> "" then apptobj.Fields("http://schemas.microsoft.com/mapi/id/{00062002-0000-0000-C000-000000000046}/0x8234").value
= upto
apptobj.Fields.update
apptobj.close
uptoid = ""
upto = ""
end if
susapt = 0
oRecSet.MoveNext
wend
oRecSet.Close
oConn.Close
Set oRecSet = Nothing
Set oConn = Nothing
End Sub

Popular posts from this blog

The MailboxConcurrency limit and using Batching in the Microsoft Graph API

If your getting an error such as Application is over its MailboxConcurrency limit while using the Microsoft Graph API this post may help you understand why. Background   The Mailbox  concurrency limit when your using the Graph API is 4 as per https://docs.microsoft.com/en-us/graph/throttling#outlook-service-limits . This is evaluated for each app ID and mailbox combination so this means you can have different apps running under the same credentials and the poor behavior of one won't cause the other to be throttled. If you compared that to EWS you could have up to 27 concurrent connections but they are shared across all apps on a first come first served basis. Batching Batching in the Graph API is a way of combining multiple requests into a single HTTP request. Batching in the Exchange Mail API's EWS and MAPI has been around for a long time and its common, for email Apps to process large numbers of smaller items for a variety of reasons.  Batching in the Gr...

Sending a Message in Exchange Online via REST from an Arduino MKR1000

This is part 2 of my MKR1000 article, in this previous post  I looked at sending a Message via EWS using Basic Authentication.  In this Post I'll look at using the new Outlook REST API  which requires using OAuth authentication to get an Access Token. The prerequisites for this sketch are the same as in the other post with the addition of the ArduinoJson library  https://github.com/bblanchon/ArduinoJson  which is used to parse the Authentication Results to extract the Access Token. Also the SSL certificates for the login.windows.net  and outlook.office365.com need to be uploaded to the devices using the wifi101 Firmware updater. To use Token Authentication you need to register an Application in Azure https://msdn.microsoft.com/en-us/office/office365/howto/add-common-consent-manually  with the Mail.Send permission. The application should be a Native Client app that use the Out of Band Callback urn:ietf:wg:oauth:2.0:oob. You ...

How to test SMTP using Opportunistic TLS with Powershell and grab the public certificate a SMTP server is using

Most email services these day employ Opportunistic TLS when trying to send Messages which means that wherever possible the Messages will be encrypted rather then the plain text legacy of SMTP.  This method was defined in RFC 3207 "SMTP Service Extension for Secure SMTP over Transport Layer Security" and  there's a quite a good explanation of Opportunistic TLS on Wikipedia  https://en.wikipedia.org/wiki/Opportunistic_TLS .  This is used for both Server to Server (eg MTA to MTA) and Client to server (Eg a Message client like Outlook which acts as a MSA) the later being generally Authenticated. Basically it allows you to have a normal plain text SMTP conversation that is then upgraded to TLS using the STARTTLS verb. Not all servers will support this verb so if its not supported then a message is just sent as Plain text. TLS relies on PKI certificates and the administrative issue s that come around certificate management like expired certificates which is why ...
All sample scripts and source code is provided by for illustrative purposes only. All examples are untested in different environments and therefore, I cannot guarantee or imply reliability, serviceability, or function of these programs.

All code contained herein is provided to you "AS IS" without any warranties of any kind. The implied warranties of non-infringement, merchantability and fitness for a particular purpose are expressly disclaimed.