Email downloading not working

Hi, I’m trying to download an email as described in the documentation using the folowing code
import stream from “stream”;
import { promisify } from “util”;
import fs from “fs”;
import got from “got”;
import { simpleParser } from “mailparser”;

const pipeline = promisify(stream.pipeline);
await pipeline(,

// Now read the file and parse its contents into the parsed variable
// See Mailparser :: Nodemailer for parsing options
const f = fs.readFileSync(/tmp/raw_email);
this.parsed = await simpleParser(f);

but steps.trigger.event.mail.content_url is undefined.
I tried also steps.trigger.event.attachements.contentUrl but it’s failing too.


Hi @casarecords38

First off, welcome to the Pipedream community. Happy to have you!

Thanks for sharing the code, very helpful to follow along.

Just double checking, but are you pasting this code into the run function?

The Node.js code step comes with scaffolding that looks like the below:

export default defineComponent({
  async run({ $ }) {
     // place your custom code in here

Without that structure, your code step won’t be able to function properly.

Here’s a link to our documentation about this topic specifically:

And a short video as an explainer:

Hi Pierce,

here is my code

export default defineComponent({
props: {
sendgrid: {
type: “app”,
app: “sendgrid”,

async run({ steps, $ }) {
const url = steps.trigger.event.mail.content_url

And I am getting this error when I try to execute it

Cannot read property ‘content_url’ of undefined

    at (file:///tmp/__pdg__/dist/code/673ef0ebffa705d73ef36436ead5414b3b0d1ad7de98aca160cd8d52d8763d33/component.mjs:27:42)
    at global.executeComponent (/var/task/launch_worker.js:146:53)
    at MessagePort.messageHandler (/var/task/launch_worker.js:618:28)

Question : which URL shall I pass to if my trigger is an email with an attachement ?

Hi @casarecords38

A TypeError is Javascript trying to tell you that the property you’re attempting to access doesn’t exist.

Please double check the incoming variable from the step exports and make sure those properties exist.

Specifically, I recommend logging the content of steps.trigger.event, I would guess you’re missing an extra body property, then going into mail.content_url.

Hi Pierce,

today, I was about to progress on this but it’s look like i cannot access and edit anymore my workflow.
I am getting this screen “preparing” without any possibility to edit trigger & steps.

I’ve tried to build a new flow but the result is the same.
Is there something wrong with my account ?

Hi @casarecords38

We have restarted our main API which powers the building experience for both v1 and v2.

The good news is that deployed workflows should not have been affected, it was just an issue of the API connecting to the events database.

We’re still monitoring to verify that this issue is resolved, the status page here is the main source of truth:

Thanks for your patience!