Bring back the Cloudy to Cloudy Attachments

Feature Description

Outlook 2016 adds some fundamental attachment handling features that allow you by default to treat “links” to a shared cloud file as an attachment. This feature set is sometimes referred to informally as “cloudy attachments”. Other Microsoft mail clients such as the web clients for Outlook.com and Office 365, and the mail client that ships as a built-in app for Windows 10 will likely also support this feature set going forward.

The basic architecture of the “cloudy attachment” feature is that the email message itself contains some metadata that describes the attachment. This metadata includes properties like the original URL, the permission type, etc. Mail messages are typically transported over domains using Internet protocols such as SMTP and MIMEso the metadata must be stored with the message in some way that will survive the SMTP/MIME transport.

Desktop Outlook on the other hand is natively a MAPI Mail Client so to understand metadata that is transported through SMTP, somethingmust translate the internet SMTP/MIME formatted data into MAPI data for use in outlook.

The goal of the feature is to use the metadata to render cloudy attachments in the attachment well, just as other attachments are rendered, and allow the user to interact with them the same way:

Figure 1- Cloudy Attachments

Down-Level Client Support

To support down-level clients such as Outlook 2010, thecloudy attachment data is also included directlyin the HTML body of the message using a special comment syntax that the Office applications understand. This creates a visible “link” for recipients to click on when their client version does not support cloudy attachments. This HMTL rendering of the attachments can also be used by non-Microsoft clients such as Gmail.When the down-level clientsdisplay the HTML, the result looks like this:

Figure 2- HTML Rendering of Attachment Data

Unexpected Attachment Behavior

As the feature has matured most of these MAPI/MIME/HTML translation scenarios happen correctly as messages with cloudy attachments travel between different mail systems. However, due to the multitude of client versions, transports, etc., there are some corner cases that yield unexpected results. One specific scenario is interesting. Consider that you receive emails in Outlook 2016 where the metadata is not complete, but the “backup” HTML data is present. Normally this would be a good fallback experience. Outlook would not be able to render the cloudy attachment natively in the attachment well, but you would still be able to access the attachment using the HTML data in the body of the message. Unfortunately, some builds of Outlook 2016expect that they will always be able to parse and render the cloudy attachments in the attachment well using the metadata, so they purposefully HIDE the HTML body data. The reasoning is that since Outlook will always show you the native, “better” attachment experience up in the attachment well you will never need to see the HTML rendering.

This scenario could show up symptomatically like this:

  1. A sender sends an email from Outlook 2016 to you and several other recipients that includes a new cloudy attachment
  2. Something along the mail delivery path does not translate or allow the Internet headers to successfully arrive. One example might be Exchange Server 2010, which does not have knowledge of cloudy attachments
  3. You open the message with Outlook 2016
  4. Another recipient open the message with Outlook 2010

In this case, the OL2010 recipients will see the attachment link in the HTML body and be happy. You will not see the attachment link in the HTML body because Outlook 2016 has hidden it. You will also not see the attachment data in the attachment well because the metadata was lost during MIME/MAPI translation. You are not happy. To create further confusion, you open the same message from a different Outlook 2016 client and the HTML is shown successfully.

Figure 3- Outlook 2016 Build Hiding the HTML Attachment Data

Figure 4- Outlook 2016 Build Showing the HTML Attachment Data

Workarounds

If you receive an email that you expect to have a cloudy attachment and it is not visible in the attachment well OR the HTML in the body of the message, use these steps to determine if the attachment link data is present in the HTML and being hidden purposefully by outlook.

  1. Double-Click to open the message in a window of its own
  2. From the Move group in the ribbon, click on the actions choice, and then choose “View in Browser”
  3. In the resulting browser window, look for the attachment links
  4. If there are cloudy attachment links in the HTML body you can access and open the link from the browser window

Figure 5- Web Browser Rendering of Source HTML

Macro Example to Unhide the HTML attachment data

As mentioned before, the “backup” attachment data is just standard HTML data surrounded by some special comment tags that Office uses to make decisions with regards to rendering. Since the Outlook object model allows access to the HTML body of mail messages, we can write a helper macro to change the underlying HTML so that Outlook always shows the HTML attachment data if its present.

Warning: This sample assumes you are familiar with creation and execution of macros in Outlook. It will also change the HTML of the message on which the macro is run, so you should make a copy of the message first to be safe.

Sample Steps to create a “helper” button

  1. Use the VBA Editor (Alt-F11) to add code for the sample macros (see sample code below)
  2. Customize the Explorer ribbon and add a new group for “Attachment Tools” and buttons to run the Show and Hide macros
  3. With the problem message selected in the main message list of Outlook, click the button to run the macro

Figure 6- Sample Ribbon Customization

Sample Macro Code

Sub ExplorerShowCloudy()

Dim citem As MailItem

Dim oEntryID As String

Dim cHTML, nHTML As String

Set citem = Application.ActiveExplorer.Selection.Item(1)

oEntryID = citem.EntryID

cHTML = citem.HTMLBody

nHTML = Replace(cHTML, "if lte mso 15 || CheckWebRef", "if gte mso 9 || CheckWebRef")

citem.HTMLBody = nHTML

citem.Save

Set citem = Nothing

End Sub

Sub ExplorerHideCloudy()

Dim citem As MailItem

Dim oEntryID As String

Dim cHTML, nHTML As String

Set citem = Application.ActiveExplorer.Selection.Item(1)

oEntryID = citem.EntryID

cHTML = citem.HTMLBody

nHTML = Replace(cHTML, "if gte mso 9 || CheckWebRef", "if lte mso 15 || CheckWebRef")

citem.HTMLBody = nHTML

citem.Save

Set citem = Nothing

End Sub

This code is a sample to show the ability to manipulate the HTML body. It is very limited (for example it only works on mail items, not meeting requests) and should just be used as a sample from which to build a full helper macro.

Recap

  • Outlook 2016 has new cool attachment features that help you share and collaborate on attachments from Web locations
  • Down-level support is provided using HTML tags in the body of the message
  • Outlook 2016 typically hides the HTML rendering and shows the attachments natively in the attachment well
  • In some corner cases, Outlook is unable to render the cloudy attachments, and you can use “View in Brower” as a workaround

Backing Data Examples

For reference, here are examples of the “metadata” both in Internet format and MAPI format, and the HTML “backup” text.

Data Type / Example
SMTP/MIME Headers / Subject: Test Cloud Attach Two
Date: Thu, 1 Sep 2016 18:41:30 -0400
MIME-Version: 1.0
Content-Type: multipart/related;
boundary="----=_NextPart_000_0911_01D20480.74A6D020"
Document-Reference: https%3a%2f%2f1drv.ms%2fw%2fsAAAAAAWX03Lba6Ng797-9D-6HYd7H7fvA;FileName=sample.docx;ProviderType=OneDriveConsumer;Permission=View;
Mapi Attachment Properties /
HTML with Office “comments” / <!--[if lte mso 15 || CheckWebRef]--<div id="OwaReferenceAttachments" contenteditable="false"<table style="margin-bottom: 15px; border-width: 0px 0px 1px 0px; border-color:#C7C7C7; border-style: none none dotted none;"<tbody<tr valign="top"<td style="padding-bottom:7px;"<table align="left" style="margin-right: 28px; border-width: 0px; background-color: rgb(255, 255, 255); border-spacing: 0px"<tbody<tr valign="top"<td style="padding: 0px;"<div id="OwaReferenceAttachmentDescription" style="margin-left: 3px;"<p style="white-space: nowrap; margin-bottom: 4px; font-size: 14px; font-weight: normal; font-family: 'Segoe UI', 'Segoe WP', 'Segoe UI WPC', Tahoma, Arial, sans-serif; color: #666666;">Some User has shared a OneDrive file with you. To view it, click the link below.</p</div</td</tr</tbody</table</td</tr<tr valign="top"<td<table valign="top" style="margin-right: 28px; margin-bottom:10px; border-width: 0px; height:20px; background-color: rgb(255, 255, 255); border-spacing: 0px"<tbody<tr valign="top"<td style="padding: 0px;"<div style="background-color: rgb(255, 255, 255); height: 20px; width: 20px; max-height: 20px;"<img height="20" width="20" style="border:0px" src="cid:12540" alt="icon"</div</td<td<div id="OwaReferenceAttachmentFileName2" style="margin: 0px 0px 0px 5px; font-size: 14px; font-family: 'Segoe UI', 'Segoe WP', 'Segoe UI WPC', Tahoma, Arial, sans-serif; color: rgb(0, 114, 198);"<a href=" target="_blank" style="text-decoration: none; margin: 0px; font-size: 14px; font-family: 'Segoe UI', 'Segoe WP', 'Segoe UI WPC', Tahoma, Arial, sans-serif; color: rgb(0, 114, 198);">sample.docx</a</div</td</tr</tbody</table</td</tr</tbody</table</div<br<div id="OwaReferenceAttachmentsEnd" style="display:none;visibility:hidden;"</div<!--[endif]-->