Quantcast
Channel: Active questions tagged email - Stack Overflow
Viewing all articles
Browse latest Browse all 29925

Email to JSON via Python

$
0
0

I have the following information from an email:

-url.server

-port

-protocol

-user

-pass

How could I, using Python, store the email content into a JSON of the form:

headers:

header_key1: value

header_key2: value

subject: "The email subject as utf-8 string"

datetime: "2015-03-17 17:48:06"

encoding: "utf-8"

from:

  • { name: "Sender Name", email: "sender@email.com" }

to:

  • { name: "Recipient Name", email: "recpient@email.com" }
  • { name: "Recipient Name 2", email: "recpient2@email.com" }

cc:

  • { name: "Recipient Name", email: "recpient@email.com" }
  • { name: "Recipient Name 2", email: "recpient2@email.com" }

parts:

  • { content_type: "text/plain", content: "body of this part", "headers": { "header_key1": value, "header_key2": value } }

  • { content_type: "text/html", content: "body of this part", "headers": { "header_key1": value, "header_key2": value } }

attachments:

  • { filename": "invoice.pdf", content_type: "application/pdf", content: "base64 of binary data" }

  • { filename": "invoice2.pdf", content_type: "application/pdf", content: "base64 of binary data" }


Viewing all articles
Browse latest Browse all 29925

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>