Anthony Chu Contact Me

Saving Mail Attachments to Blob Storage with Logic Apps

Thursday, June 8, 2017

When I was working on a Logic App to save email attachments to Blob Storage, I ran into an error:

InvalidTemplate. Unable to process template language expressions in action 'Create_blob' inputs at line '1' and column '2656': 'The template language function 'base64ToBinary' expects its parameter to be a string. The provided value is of type 'Null'. Please see for usage details.'.

Logic Apps error

Debugging a Logic App

The Logic App itself is pretty straight forward:

Original Logic App

So what's the problem? The error message is pretty cryptic, but thankfully Logic Apps are easy to debug. If we open up a failed run, we're able to inspect the inputs and outputs of each step.

Since it's complaining about something being Null in the Create Blob step, we can take a look at the output of the step before. Particularly, we want to see the two values that we're using: Name and Content.


We see that the attachment contents (ContentBytes) is null.

Including the attachment content

It turns out that the default behavior of the Office 365 Outlook connector does not download attachments. And I guess it makes sense, since attachments can be huge.

There's an Office 365 Outlook Get Attachment action that we can use in our loop to download each attachment.

But there's an easier way. We can open the When A New Email Arrives task and expand the advanced options:

Include attachments

All we have to do is enable the Include Attachments option and the Logic App will work!