Emailing List Attachments in Office 365

Hello all! It’s been at least two years since I have posted something technical on my Salty Blog, pathetic right?. This how-to in my opinion was too good not to share as I believe that it will help others that are facing/have faced this issue.

The ability to email attachments from a list is one of those pain points that I seem to face all of the time. This documentation will take you through the process of setting up a new Flow that will grab all attachments for a single list item and will then email those attachments back out to the intended target.

Before I begin, let me preface this post stating that I did not come up with this. I found a couple of posts and podcasts but I wanted to compile this working version into one blog post.

I was searching for an answer on this issue late last year and attending one of Laura Roger’s weekly Power Hours and she presented on this. Here is a link to that original broadcast: SharePoint Power Hour: Flow Attachments & Files . If you follow the recording to the end, you will notice that Flow was not behaving properly. Well, I could not get it to work either and after a month of trying different things, I gave up.

A couple of months later I, I received an update from Microsoft’s Blog on Flow which is named Flow of the Week. This particular flow caught my eye: Send multiple attachments on a single email. I couldn’t believe it! This was exactly what the doctor ordered or at least I thought it was. I had setup the Flow as explained in the blog post but when I would run the Flow, I would receive the following message: “No input parameters provided. Please provide required input parameters ‘To’, ‘Subject’ and ‘Body'”

You’ve got to be kidding me!!!!!! Why is this not working for me?!?!?!?! I just want to send an email with the list attachments!!!!! I need this to work!!!!!

Ok, calm down……… After a couple of weeks had passed and after I tried all that I could think of to get around this error, I went back to that Microsoft blog post and noticed a comment by Vytenis Jazbutis. He explains how he was able to get around this with a “fix” for the issue of the final “send email” step. It doesn’t like and doesn’t want to add the full “file content” file from the array as an email attachment. What it wants instead is the .$content property within the file contained in the array.

I have decided to recreate the blog post showing the new way of grabbing the attachments with Vytenis’s fix. Once again, all props goes to Laura, Sunay and Vytenis of this.

With that being said, let’s dive into this and build out this Flow!

  1. Add a new “SharePoint – Create item” trigger and select the correct SharePoint Site and List.
    *** Please ensure that you already have SP List created that allows storing multiple attachments on the items in it.
  2. Add a new “Schedule – Delay” step
    *** I added this additional “Delay Step” because I was getting inconsistent results. Sometimes the trigger would fire too early and would send a blank email without grabbing the attachments. By adding this 30 second delay, it will give Flow the ability to run each step in the process before sending the email. You may not need this in your environment but in my experience even with SharePoint Designer workflows, I have to add these more often than not.
  3. Add a new “SharePoint – Get attachments” step

    *** This step will be grab all of the attachments added to the newly created list item. Use the Site name and List name from the previous step. We want to then pipe the output “ID” from the trigger, to the input ‘ID’ field.
  4. Add a new “Variables – Initialize variable” step
    *** This variable will be used to store all of the attachments in a single array.
  5. Add an “Apply to each” step.
    1. Click inside of the *Select an output box and click the “Body” output from the “Get attachments” section
    2. Click the “Add an action” button and select “SharePoint – Get attachment content”
    3. For the ID field, select the “ID” output from the “When an item is created” trigger section
    4. For the File Identifier field, select the “Id” output from the “Get attachments” section
    5. Click the “Add an action” and select “Variables – Append to array variable”
      1. For the Name field, select “attachmentArray” from the dropdown. (this was created in step 4)
      2. For the Value field, type in the following JSON statement:
        1. For “ContentBytes”, click between the : and , and then click on the “Expression” output
        2. Type in the following expression: body(‘Get_attachment_content’).$content and click the ‘OK’ button
          *** “Get_attachment_content” is the name of the step created in 5b. Don’t forget the underscores for spaces.
      3. For “Name”, click between the ” and : and select the “DisplayName” output from the “Get attachments” section
        *** See “Note” below on additional details about the “ContentBytes” parameter
        The completed step should look like the one seen here
  6. Add a new “Office 365 Outlook – Send an email” step
    *** Note: Use whatever mail client that you have setup to run this step.

    1. Fill in all of the required fields (if applicable to your mail client).
      *** I have a list value that I am using to populate my “To” field.
    2. Click the “T” icon next to the Attachments Name field. This switch will change the attachments control from “Detail inputs for array item” to “Input the entire array”
    3. For the Attachments field, select “attachmentArray” from the “Variables” section.

  7. The completed Flow should look like the following:

Save your Flow, then go to your list and create a new list item with attachment(s) to test. Remember to be patient if you put in the delay step. You should receive an email with the attachment(s) that you added to the list item.

This solves a lot of issues that I was having and I hope that it will help you in some way.

Stay Salty!

A No-No for having Multiple SPD Workflows for Lists/Libraries

Word of warning:

If you need to have more than one workflow for a particular list/library, DO NOT copy a SPD workflow and paste back into the same library.

What happens is that even if you change all of the properties of the files (names, etc.), there is still a hidden property that SharePoint likes to hold on to and uses to identify the workflow.  Think of it as an ID.

Basically, you will have two different workflows with the same ID.  When you publish one of these to a list/library, everything works fine.  When you go to publish the second one, everything seems fine but after close evaluation, you will notice that the first workflow that you published is no longer attached to the list/library.

Moral of the story, don’t be lazy.  Create a new workflow even if all of the information is the same.

Need to edit multiple items to kick off a workflow? No prob Bob!

I was faced with this task recently.  Let me paint the picture for you.

I have a document library with over 1,000 items in it.  I added a new column (Named) that needs to have the same information as an existing column (Name).  For whatever reason, the web part I am using for my list search does not recognize the existing column.  I created a SP Designer workflow to copy the contents from the ‘Name’ to the ‘Named’ on creation or edit.

To do this, there are a couple of options.

  1. The long drawn out option – Edit each file individually
  2. The best option for me – Content and Structure
  3. Power option – SharePoint Designer

I went with option 2 because I did not want to lag the server with a whole lot of who ha.  Here are the steps I followed to make this happen.

  1. Go to the site, Site Settings, Content and Structure
  2. Expand the library to perform this action
    01
  3. Place a check into the ‘Select All’ check box
    02
  4. Click on the ‘Actions’ drop down and select ‘Check Out’
    03
  5. Once checked out (you may have to do this twice), click the ‘Actions’ drop down and select ‘Check In’
    04

Make sure to check that you have performed this action for all items in your view.  Mine were in groups of 100, which is generally the standard view.  The fasted option for me would have been the SharePoint Designer route but I did not want to take a chance of checking out over 1,000 items at once and then check them back in.  We already have enough load on the servers from all of the other users accessing SharePoint.