IMAP Read Mail cannot get plain text

Hi!

I’m trying to create a simple workflow that stores every new mail from Venmo & Paypal to Google Sheets and for that, I need plain text, however, because Venmo and Paypal send HTML mails I cannot get that. When I tried the same workflow with Zapier it gave me a plain text from Venmo mails. Is there a way to get plain text from those emails on n8n?

Welcome to the community @Josip_Ivancevic!

Are you sure there is no plain text version of the email? I would expect that it is there but you simply have to scroll down a lot as the HTML version is so long and the fields are vertically centered. Probably easier to switch to JSON-View.

Yes, I scrolled to the middle where there is metadata, date, subject and other data but for some reason there is no plain text.
Also I tried the same workflow with my test plain text mail and it worked.

In this case, does the email did not get sent with a plain text version. So you would have to make it yourself with a HTML Extract node.

Here an example:

{
  "nodes": [
    {
      "parameters": {
        "values": {
          "string": [
            {
              "name": "html",
              "value": "<body><strong>some bold text</strong> other text</body>"
            }
          ]
        },
        "options": {}
      },
      "name": "Set",
      "type": "n8n-nodes-base.set",
      "typeVersion": 1,
      "position": [
        430,
        376
      ]
    },
    {
      "parameters": {
        "dataPropertyName": "html",
        "extractionValues": {
          "values": [
            {
              "key": "text",
              "cssSelector": "body"
            }
          ]
        },
        "options": {}
      },
      "name": "HTML Extract",
      "type": "n8n-nodes-base.htmlExtract",
      "typeVersion": 1,
      "position": [
        630,
        376
      ]
    }
  ],
  "connections": {
    "Set": {
      "main": [
        [
          {
            "node": "HTML Extract",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
1 Like

Thanks Jan! It worked for Venmo mails that have pure HTML as a JSON parameter, however, for Paypal mails that have binary data nested in a JSON object (as in the screenshot above) I had to write a function to extract that data to HTML, and then to plain text.

I’m pasting code snippet if anyone finds himself in the same situation as I did.

1 Like

Great, thanks a lot for sharing! Very appreciated!

Have fun!

1 Like