Skip to main content

Setting the Homepage on a Outlook Folder via a script

I’ve had a number of people ask this question in the past so I thought I’d post up a script to help out those they may want to look at doing this.

When you set the Outlook homepage within Outlook it configures the PR_FOLDER_WEBVIEWINFO or http://schemas.microsoft.com/mapi/proptag/0x36DF0102 property. This property is a Binary property who’s format is undocumented but using a Mapi editor like OutlookSpy or MfcMapi you can work out the format that this follows. The basic format is

dwVersion: 0x00000002
dwType: 0x00000001
dwFlags: 0x00000001
dwUnused: 0x0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000
cbData: 0x188 (000000BC)
bData: http://yoururl.com

If you want to set this property in a script the 3 values you need to worry about are

dwFlags If this is set to 1 then the check box in Outlook for “Show homepage by default for this folder” will be checked.

cbData is the number of bytes (8 bits or 2 hex digits) or the url in Bdata + the spacers

bData is the URL of the webpage you want to point to encoded in Hex.

The following script handles encoding URL’s that are up to 255 characters long if you want to have URL’s that are longer than 255 charterers then you need to change the code for cbData. The rest of the code builds the binary property. The AsciiToHex to function encodes the Ascii string 1 byte for each letter hence the extra padding needed.

The one thing to note is this is a unsupported thing to do so make sure you do plenty of your own testing first.

I’ve created 2 versions of the script one version uses codex and the other cdo1.2 they do basically the same thing. They first check for an instance of a folder in a mailbox (the cdo1.2 version only checks the Root folder). If an instance of that folder is found then its sets the homepage property on the folder else it creates the folder and sets the homepage. In this sample the folder is called webfolder and it sets the homepage of that folder to a search about coffee tasting in Sydney.

I’ve put a downloadable copy of the script here the code itself looks like.

homepage = "http://yoururl.com"
dwVersion = "02"
dwType = "00000001"
dwFlags = "00000001"
dwUnused = "00000000000000000000000000000000000000000000000000000000"
bData = AsciiToHex(homepage)
cbDataSize = cstr(ubound(bData)+1)
propval = dwVersion & dwType & dwFlags & dwUnused & "000000" & Hex(cbDataSize) & "000000" & Join(bData,"")

set rec = createobject("ADODB.Record")
rec.open "file://./backofficestorage/domain.com/MBX/mailbox/webfolder/", ,3,33562624
rec.fields("http://schemas.microsoft.com/mapi/proptag/0x36DF0102").value = propval
rec.fields.update
rec.close


Function AsciiToHex(sData)
Dim i, aTmp()
ReDim aTmp((Len(sData)*2) + 1)
arnum = 0
For i = 1 To Len(sData)
aTmp(arnum) = Hex(Asc(Mid(sData, i)))
arnum = arnum + 1
aTmp(arnum) = "00"
arnum = arnum + 1
Next
aTmp(arnum) = "00"
arnum = arnum + 1
aTmp(arnum) = "00"
ASCIItoHex = aTmp
End Function

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-

How to access and restore deleted Items (Recoverable Items) in the Exchange Online Mailbox dumpster with the Microsoft Graph API and PowerShell

As the information on how to do this would cover multiple posts, I've bound this into a series of mini post docs in my GitHub Repo to try and make this subject a little easier to understand and hopefully navigate for most people.   The Binder index is  https://gscales.github.io/Graph-Powershell-101-Binder/   The topics covered are How you can access the Recoverable Items Folders (and get the size of these folders)  How you can access and search for items in the Deletions and Purges Folders and also how you can Export an item to an Eml from that folder How you can Restore a Deleted Item back to the folder it was deleted from (using the Last Active Parent FolderId) and the sample script is located  https://github.com/gscales/Powershell-Scripts/blob/master/Graph101/Dumpster.ps1

Using the MSAL (Microsoft Authentication Library) in EWS with Office365

Last July Microsoft announced here they would be disabling basic authentication in EWS on October 13 2020 which is now a little over a year away. Given the amount of time that has passed since the announcement any line of business applications or third party applications that you use that had been using Basic authentication should have been modified or upgraded to support using oAuth. If this isn't the case the time to take action is now. When you need to migrate a .NET app or script you have using EWS and basic Authentication you have two Authentication libraries you can choose from ADAL - Azure AD Authentication Library (uses the v1 Azure AD Endpoint) MSAL - Microsoft Authentication Library (uses the v2 Microsoft Identity Platform Endpoint) the most common library you will come across in use is the ADAL libraries because its been around the longest, has good support across a number of languages and allows complex authentications scenarios with support for SAML etc. The
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.