Thursday, August 27, 2015

OWA Voting Buttons Compose App for Office365/Exchange 2016

OWA or Outlook on the Web have never quite had the feature parity with the desktop version of Outlook which can be a point of frustration for those primarily using it. Although interesting in Office365 new features like clutter, sweep etc are now lighting up in the OWA first before they make their way into new desktop releases. One of the things you haven't been able to do previously with OWA is create an Email with voting buttons. With compose apps and some of the recent changes in version 1.3 of the API which I posted about here, you now have the ability to add some of this functionality back in. Actually with a little imagination you also have the ability to actually build something a lot better then the voting buttons feature which have been around in Exchange for some time. But in this post I want to show how you can create a Compose Mail App that uses EWS to make changes to the draft message to enable the feature.

One thing also to note is that creating an Email with Voting buttons isn't supported also in EWS  so I'm using a workaround of generating the PidLidVerbStream property value using the documentation from https://msdn.microsoft.com/en-us/library/ee218541(v=exchg.80).aspx . The one issue you can have is if you don't get the value of this property correct this can cause Outlook to crash (which means you then need to delete the offending item with mfcMapi). So this Mail App would be unsupported, experimental and largely untested.

Here's a screenshot of what the Apps looks like in Action


After you select the Voting option you want you need to hit the Save button which will invoke the actions to modify the draft message.

I've put the code for this MailApp up on my GitHub repo https://github.com/gscales/MailApps/tree/master/OWAVoting  if you decide to test it and find any bugs please submit them back. As I mentioned before you should consider this experimental only. All the code is included in the script.js file and uses the workaround I described here as this was only a test app I haven't put any error processing in the Aysnc callbacks.

Setting properties via EWS on a Draft message in a Compose Mail App

With the latest updates that have been released recently for Compose apps that are now available in OWA in Office365 and the Office/Exchange 16 preview the ability to extend what your compose apps can do has been greatly enhanced. With version 1.3 of the API you can now save an Item via the saveAsync method https://msdn.microsoft.com/en-us/library/office/mt269096.aspx .

Why this small change is important from an extensibility point of view is that when you save an Item this way, it creates a draft in the Mailbox you activated the compose app from which you can then modify anyway you like using the EWS updateItem operation. (normally you would be restricted in a compose app to just using the subset of properties and methods provided for in the Office.js).

One trick however is the ItemId which you need to make an UpdateItem EWS Request to update the Draft Item is still only available in Read Mode. So to get around this I've come up with the following workaround

  1. Set a custom property on the draft Item using the Mail App Custom properties method using something like https://msdn.microsoft.com/EN-US/library/office/fp142263.aspx . With my Mail Apps I generate a new GUID for the app session that I use as the value.
  2. Save the Item your composing as a Draft using saveAync
  3. Now you can use makeEwsRequestAsync to do a findItems on the drafts folder of the Mailbox with a restriction so it only finds the Item with the Custom property you have set. The Custom properties you can set in the Mail App API are documented in https://msdn.microsoft.com/en-us/library/hh968549(v=exchg.80).aspx . But basically what you have is they are a named property within the PS_PUBLIC_STRING propset of type String. The property name of the property is prefixed with cecp- and rest of the property name is the GUID of your Mail Apps as defined in the application's manifest Id .
  4. Once you have the ItemId and Change key you can then use UpdateItem in EWS to update any of the extended or strongly type properties on the draft Message.
One thing to note to use this workaround your Mail App needs the ReadWriteMailbox privilege to allow the use of the EWS Operations. I've put together a sample of using this workaround in my OWA Voting button app.

Also because this is using version 1.3 of the Mail App Api you should set the requirements in the Manifest file of your application eg

  <Requirements>
    <Sets DefaultMinVersion="1.3">
      <Set MinVersion="1.3" Name="Mailbox"></Set>
    </Sets>
  </Requirements>

This will mean your Mail App will only activate in clients that support version 1.3 which means at the moment it won't activate in Outlook 2013.

Saturday, August 08, 2015

Text Emoticon Outlook and OWA Compose App

Emojis and emoticons have been around for quite a while but are picking up a bit of steam of late with the release of Windows 10. The Daily mail had a really good article on their use recently which is worth a read.

Like everything these new emoji's have there origins story and text based emoticons (which have many other names) are kind of a interesting sub branch with a slightly retro feel.

In this post I'm going to show you how you can create a Mail App to make using text emoticon's easy in Exchange 2013 and Office365 using the new compose apps feature which was introduced last year at MEC.

Compose apps are one way of easily extending the User interface in OWA and Outlook 2013 (and 2016). So for this example I can do something like the following to make these text emoticons easy to insert into either the Subject or Body of a message (you need to active the app by selecting the Addin Button in OWA or Apps for Office in Outlook)


At this point it should be noted the Unicode support in Email subjects is a relative new thing the RFC came out in 1996 https://tools.ietf.org/html/rfc2047 full Unicode support in Outlook didn't really happen until 2003. So if your sending to someone still rocking old versions be warned actually because of the difference in the implementation of character sets and available between different platforms windows/android/ios etc some of these text base emoticons may only display correctly on some platforms/browsers/mail clients. But you can then have hours of fun filling you mailbox with this type of stuff



Mail Apps are relatively simple to implement and this is a pretty straight forward example the first thing you have is the Manifest file where all the configuration information is held for this Mail App. Eg in my app some of the important relative information is

 <FormSettings>
    <Form xsi:type="ItemEdit">
      <DesktopSettings>
        <SourceLocation DefaultValue=
          "https://gscales.github.io/TextEmoticon/index.html" />
      </DesktopSettings>
      <TabletSettings>
        <SourceLocation DefaultValue=
          "https://gscales.github.io/TextEmoticon/index.html" />
      </TabletSettings>
      <PhoneSettings>
        <SourceLocation DefaultValue=
          "https://gscales.github.io/TextEmoticon/index.html" />
      </PhoneSettings>
    </Form>
  </FormSettings>

This tells us where the Mail App is being hosted is my case just in my GitHub Repo to learn more about the other manifest setting have a read of this. The Mail App itself is just a pretty simple html and javascript app that creates a table and reads in the text emoticons and controls the formatting and takes care of the backend operations by hooking into the JavaScript Api for office.

In the script.js for this app when you select the Subject object and click a text emoticon to insert your chosen Icon it will append this to the current subject (there is no way to do a positional insert based on the current position of the cursor in the subject. For the body you can insert the Icon at the current cursor location using the method from https://msdn.microsoft.com/EN-US/library/office/dn574748.aspx#mod_off15_HowToInsertDataBody_AtCursor

I've posted the code for this up into my GitHub repo at https://github.com/gscales/gscales.github.io/tree/master/TextEmoticon  if you want to test it you can install the app from the manifest at  https://gscales.github.io/TextEmoticon/manifest.xml . Although I'd recommend you clone it yourself and then you can change the text emoticons in the script.js file to whatever you like. If you do clone the repository you need to change the (the source location settings shown above) settings in the Manifest file to ensure its pointing at the files your hosting or you will never see your changes take affect.