Skip to main content

Setting the Appointment Label Text Programmatically

Last week I blogged this Appointment label Colour Changing Event Sink and I mentioned that the appointment label text is located in the http://schemas.microsoft.com/mapi/proptag/0x36DC0102 property in an undocumented binary form. Well I had a crack at working out what that format is this week and I've come up with the following sample.

Before I start though I must give the following warning, the following piece of code and method is completely unsupported and completely untested. Playing around with binary properties is very unwise unless you really have a good enough grasp to be able to undo any damage you may do trying to set them. The third and last bit is that this will only work if your using the ASCII character set. If you're using other types of character sets (eg a lot of Asian character sets) this wont work.

Because this property is stored in a binary format to work with this in VBS we need something that can read binary and convert it to a hex string which makes it usable. For this I've used Arrayconvert out of this KB article. This library works well and it free and easy to use, the only thing it doesn't do is convert directly a string to hex but you can do this indirectly by first converting the sting to binary and then to hex.

So when no customizations have been made to the labels this property is set to a hex value of 44 Zero's (I know this is not a proper explanation of binary). Or as I'm going to deal with it in the script its 11 groups of "0000". As we have 10 labels then 10 of these groups represent a spacer for each label and the lasts group represents the padding to begin. These groups of 0's are constants in this property they only change in location in relation to the text that's being inserted into the labels.

So the major task that this script does is builds the hex string to be inserted into the property. The first thing it does is sets up a 10 element array to hold all the spacer values for each label. (We already know that this property is going to start with "0000"). The next thing it does is setups up a 10 element array to hold the values for all the customized label texts.

The next part of code then loops through the spacer array and checks to see if any text is going to be inserted from the corresponding label array. If text has been set in that label array element it then first converts the text to a hex string (by way of converting it to binary then back to hex). Then because each character is given 4 digits for storage and USASCII only uses the first 2 digits the hex string is split apart and each hex character representation is padded with "00".

So what we end up with is a hex string representing all the values and spacers that need to be set. Some Exoledb/ADO code is then used to set the x36DC0102 property using the arrayconvert library to convert this hex string into the octent Variant Array of bytes needed for this property.

Thats it as I said you should view this code as experimental and highly suspect. I've posted a downloadable copy of the code here. In my example I'm only setting the two values for blue and green to Internal and External. Eg.

dim objspcarray(9)
dim objlabelarray(9)
set rec = createobject("ADODB.Record")
Set cnvt = CreateObject("ADs.ArrayConvert")
objspcarray(0) = "0000"
objspcarray(1) = "0000"
objspcarray(2) = "0000"
objspcarray(3) = "0000"
objspcarray(4) = "0000"
objspcarray(5) = "0000"
objspcarray(6) = "0000"
objspcarray(7) = "0000"
objspcarray(8) = "0000"
objspcarray(9) = "0000"
objlabelarray(0) = ""
objlabelarray(1) = "External"
objlabelarray(2) = "Internal"
objlabelarray(3) = ""
objlabelarray(4) = ""
objlabelarray(5) = ""
objlabelarray(6) = ""
objlabelarray(7) = ""
objlabelarray(8) = ""
objlabelarray(9) = ""
dstring = "0000"
for i = lbound(objspcarray) to ubound(objspcarray)
if objlabelarray(i) <> "" then
objtooct = cnvt.CvStr2vOctetStr(objlabelarray(i))
objtohex = cnvt.CvOctetStr2vHexStr(objtooct)
for h = 1 to len(objtohex)/2
dstring = dstring & mid(objtohex,((h*2)-1),2) & "00"
next
end if
dstring = dstring & objspcarray(i)
next
wscript.echo dstring
rec.open "file://./backofficestorage/domain/mbx/mailbox/calendar",,3
rec.fields("http://schemas.microsoft.com/mapi/proptag/x36DC0102").Value = cnvt.CvHexStr2vOctetStr(dstring)
rec.fields.update
rec.close

Popular posts from this blog

Testing and Sending email via SMTP using Opportunistic TLS and oAuth in Office365 with PowerShell

As well as EWS and Remote PowerShell (RPS) other mail protocols POP3, IMAP and SMTP have had OAuth authentication enabled in Exchange Online (Official announcement here ). A while ago I created  this script that used Opportunistic TLS to perform a Telnet style test against a SMTP server using SMTP AUTH. Now that oAuth authentication has been enabled in office365 I've updated this script to be able to use oAuth instead of SMTP Auth to test against Office365. I've also included a function to actually send a Message. Token Acquisition  To Send a Mail using oAuth you first need to get an Access token from Azure AD there are plenty of ways of doing this in PowerShell. You could use a library like MSAL or ADAL (just google your favoured method) or use a library less approach which I've included with this script . Whatever way you do this you need to make sure that your application registration  https://docs.microsoft.com/en-us/azure/active-directory/develop/quickstart-register-

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 Graph is limited to a m

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 I wrote th
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.