Send a file from Dropbox as an email attachment

Introduction

In this tutorial, you’ll learn how to create a pipe that sends a file on Dropbox as an attachment to an email. If you have a file that regularly updates on Dropbox, this is useful way to send out a regular report or update to people without opening up permissions on Dropbox or manually notifying of an update.

Specifically, you’ll learn how to:

  • Create an email that attaches a file from Dropbox
  • Send the email from an API call
  • Send the email on a schedule

Setup

To complete this tutorial, you’ll need:

Create a connection to Dropbox

First, you’ll need to connect to Dropbox in order to access the file you’d like to email. To do so, navigte to the Connection page and add a Dropbox Connection

Create an email that attaches a file from Dropbox

Next, create a new pipe that emails the attachment from Dropbox:

  1. Create a new pipe.
  2. Delete the default Execute Task by clicking on the trash icon in the upper-right of the task.
  3. Add a new Email Task.
  4. Fill out the Email Task, using your email address in the “To” for testing
  5. At the bottom of the Email Task, click on the “Add Attachments” and select the file(s) you’d like to attach to the email
  6. After saving your changes, press the “TEST” button in the upper right of the Pipe Builder.
  7. Check your inbox and you should receive an email with the attachment

Send the email using an API call

To send the email from an API call, you’ll need to set an API endpoint to trigger the pipe.

  1. First, turn on your pipe to activate it.

  2. Then, scroll down to the Deployment section and check the box next to Run using an API endpoint to see your API endpoint and API key.

  3. Next to the endpoint, which by default uses the unique pipe EID as a reference, click the Edit button to add an alias to your pipe as follows: examples-send-dropbox-file-as-email-attachment.

  4. To quickly test the endpoint, copy the HTTPS endpoint and paste it into your browser to trigger your pipe and send another email; the HTTPS endpoint will look like this (where {token} is your unique API key):

https://api.flex.io/v1/me/pipes/examples-send-dropbox-file-as-email-attachment/run?flexio_api_key={token}

Of course, now that you have your endpoint, you’re now ready to invoke it in any server or client code that allows you to make an HTTP request. Here’s an example using Curl:

curl -X POST 'https://api.flex.io/v1/me/pipes/examples-send-dropbox-file-as-email-attachment/run'
--header "Authorization: Bearer {token}"
'

Send the email on a schedule

For other situations, like sending a weekly report, you may consider simply scheduling the pipe to run automatically on a regular basis.

  1. First, turn on your pipe to activate it.
  2. In your pipe, scroll down to the bottom Deployment section and check the box next to Run on a schedule.
  3. Finally, click on “Edit” and set up the schedule you would like to use. You can turn off your pipe at any time to terminate the scheduling.