EML (.eml)

Background & Context

    • MIME type: message/rfc822
    • Electronic mail message format.
    • Used by most mail systems to save individual mail messages.
    • Textual format, with encoded binary data.
    • Supports Multipurpose Internet Mail Extensions (MIME).
    • Supports RFC 2045, RFC 2046, RFC 2047, RFC 4288, RFC 4289, and RFC 2049.

Import

  • Import["file.eml"] imports an EML file, returning an association giving basic elements of the corresponding mail message.
  • Import["file.eml",elem] imports the specified element from an EML file.
  • Import["file.eml",{elem,suba,subb,}] imports a subelement.
  • Import["file.eml",{{elem1,elem2,}}] imports multiple elements.
  • The import format can be specified with Import["file","EML"] or Import["file",{"EML",elem,}].
  • See the following reference pages for full general information:
  • Importimport from a file
    CloudImportimport from a cloud object
    ImportStringimport from a string
    ImportByteArrayimport from a byte array

Import Elements

  • General Import elements:
  • "Elements" list of elements and options available in this file
    "Summary"summary of the file
    "Rules"list of rules for all available elements
  • Basic whole-message elements:
  • "MessageSummary"association giving basic elements of the message
    "MessageElements"association giving main elements of the message
    "FullMessageElements"association giving all elements of the message
  • Import by default uses the "MessageElements" element.
  • Summary elements:
  • "From"sender name and email address
    "ToList"recipient names and addresses
    "CcList"copied recipient names and addresses
    "BccList"blind-copied recipient names and addresses
    "OriginatingDate"date and time on client from email headers
    "Subject"the subject of the email
    "BodyPreview"short preview of the message body
    "HasAttachments"whether the message contains any attachments
    "MessageID"message ID for this message
  • "MessageSummary" includes all summary elements.
  • Additional message elements:
  • "FromAddress"sender raw email address
    "FromName"sender full name
    "ToAddressList"recipient addresses
    "ToNameList"recipient full names
    "CcAddressList"copied recipient addresses
    "CcNameList"copied recipient full names
    "BccAddressList"blind-copied recipient addresses
    "BccNameList"blind-copied recipient full names
    "ReplyToList"reply-to names and addresses
    "ReplyToAddressList"reply-to addresses
    "ReplyToNameList"reply-to full names
    "Body"message body as a string
    "AttachmentList"list of processed attachments as expressions
  • "MessageElements" includes all summary and message elements excluding "BodyPreview" and "HasAttachments".
  • Subelements can also be given in the form {elem,keys} for "FullMessageElements", "MessageElements", and "MessageSummary" where keys can be any element in the association.
  • More detailed information for each email can be imported from the following categories.
  • Message-body elements:
  • "BodyPreview"short preview of the message body
    "Body"message body as a string
    "NewBodyContent"parts of the body that are not replies or forwards
    "QuotedContent"parts of the body that are quoted
  • Message identification and threading elements:
  • "MessageID"message ID for this message
    "ReplyToMessageID"ID of a message to which this replies, if any
    "ReferenceMessageIDList"ID of "reference" messages, typically on a thread
  • Message-routing elements:
  • "Precedence"declared mail precedence
    "ReturnPath"declared return path for the mail
    "ReturnReceiptRequested"whether a return receipt is requested
    "DeliveryChainHostnames"hostnames on the mail delivery chain
    "DeliveryChainRecords"full records on the mail delivery chain
  • Mail-header elements:
  • "Plaintext"complete raw email as a string
    "HeaderString"complete email headers as a string
    "HeaderRules"list of rules for all headers
    "CharacterEncoding"character encoding for email content
    "ContentType"MIME content type of email body
    "MIMEVersion"version of the MIME standard
  • Message-origination elements:
  • "OriginatingMailClient"stated type of originating mail client
    "OriginatingIPAddress"IP address of the originating client machine
    "OriginatingHostname"hostname of the originating client machine
    "OriginatingCountry"geo IP-inferred originating country
    "OriginatingDate"date and time on client from email headers
    "OriginatingTimeZone"client time zone based on email headers
    "ServerOriginatingDate"date and time on originating server
    "ServerOriginatingTimeZone"timezone of originating server
  • Attachment elements:
  • "HasAttachments"whether each message contains any attachments
    "AttachmentNames"list of attachment names
    "AttachmentList"lists of processed attachments as expressions
    "AttachmentSummaries"lists of associations giving basic attachment elements
    "AttachmentData"lists of associations giving raw encoded data and metadata
    "AttachmentDecodedData"lists of associations giving raw decoded data and metadata
    "AttachmentDetails"lists of associations giving attachment content and metadata
  • The element "AttachmentDetails" is a list giving an association for each attachment. The elements of this association are typically as follows:
  • "Name"name assigned to the attachment
    "MIMEType"MIME type of the content
    "Content"imported content
    "ContentDisposition"content disposition of the attachment
    "ModificationDate"modification date recorded for the attachment
    "ByteCount"number of bytes in the decoded content
  • The element "AttachmentDecodedData" is a list giving an association for each attachment. The elements of this association are typically as follows:
  • "Name"name assigned to the attachment
    "MIMEType"MIME type of the content
    "DecodedContent"raw decoded content as a byte array
    "ContentDisposition"content disposition of the attachment
    "ModificationDate"modification date recorded for the attachment
    "ByteCount"number of bytes in the raw decoded content
  • The element "AttachmentData" is a list giving an association for each attachment. The elements of this association are typically as follows:
  • "Name"name assigned to the attachment
    "MIMEType"MIME type of the content
    "RawContent"raw encoded content as a string
    "ContentTransferEncoding"content transfer encoding of "RawContent"
    "ContentDisposition"content disposition of the attachment
    "ModificationDate"modification date recorded for the attachment
    "ByteCount"number of bytes in the raw encoded content
  • "AttachmentSummaries" includes "Name", "MIMEType" and the "ByteCount" of the decoded contents for each attachment.

Options

  • Import option:
  • "AttachmentRules"<||>rules to control how to import attachments
  • Possible settings for "AttachmentRules" are associations containing:
  • fmtNoneimport attachments of format fmt as None
    fmtelemImport element elem when importing fmt attachments
    fmtfunuse a pure function fun on the decoded byte array
  • The format specification fmt can be any format supported by $ImportFormats or a MIME type.

Examples

open allclose all

Basic Examples  (4)

Import an electronic mail message:

Import a message summary for an EML file:

Import the message subject from an EML file:

Import the message date from an EML file:

Scope  (1)

Import specific elements of an email as an Association:

Represent as a Dataset:

Import Elements  (52)

Available Elements  (1)

List of available elements:

Data Representation  (8)

"MessageSummary"  (1)

Get a summary of the email message:

"MessageElements"  (1)

Import the message as an Association:

"FullMessageElements"  (1)

Import the message in full:

Import specific elements of an email:

"Subject"  (1)

Extract the message subject from an EML file:

"Body"  (1)

Import the message body:

"Plaintext"  (1)

Import the message in its original internet message format:

Show an interesting snippet from the plaintext:

"BodyPreview"  (2)

Import a summary of new message content:

"BodyPreview" extracts and summarizes new content in the message:

Compare with the full message content:

Content Parsing  (2)

"NewBodyContent"  (1)

Extract new unquoted body content from a message:

Compare the extracted content with the original body:

"QuotedContent"  (1)

Extract quoted content from a message:

Compare the extracted content with the original body:

Mail Address Header Elements  (19)

"From"  (1)

Import the sender's name and email address:

"FromName"  (1)

Import the sender's full name:

"FromAddress"  (1)

Import the sender's email address:

"ToList"  (1)

Import a list of recipient names and addresses:

"ToAddressList"  (1)

Import a list of recipient addresses:

"ToNameList"  (1)

Import a list of recipient names:

"CcList"  (1)

Import a list of names and addresses for copied recipients:

"CcAddressList"  (1)

Import a list of addresses for copied recipients:

"CcNameList"  (1)

Import a list of names for copied recipients:

"BccList"  (1)

Import a list of names and addresses for hidden recipients:

"BccAddressList"  (1)

Import a list of addresses for hidden recipients:

"BccNameList"  (1)

Import a list of names for hidden recipients:

"ReturnPath"  (1)

Import the return path:

"ReplyToList"  (1)

Import a list of reply-to names and addresses:

"ReplyToAddressList"  (1)

Import a list of reply-to addresses:

"ReplyToNameList"  (1)

Import a list of reply-to names:

"MessageID"  (1)

Retrieve the message ID:

"ReplyToMessageID"  (1)

Retrieve the ID of the replied-to message:

"ReferenceMessageIDList"  (1)

Retrieve the ID of the referenced messages:

General Header Elements  (4)

"HeaderString"  (1)

Import the complete mail header of the message as a string:

"HeaderRules"  (1)

Import the header of the message as a list of rules:

"CharacterEncoding"  (1)

Import the character encoding for the message:

"ContentType"  (1)

Import the MIME content type of the email body:

Advanced Header Elements  (11)

"Precedence"  (1)

Import the declared mail precedence:

"ReturnReceiptRequested"  (1)

Import any return-receipt addresses:

"DeliveryChainHostnames"  (1)

Import the list of host names in the delivery chain:

"DeliveryChainRecords"  (1)

Import the delivery chain record as an Association:

"OriginatingMailClient"  (1)

Determine the mail client used to send the message:

"OriginatingIPAddress"  (1)

Import the IP address of the machine used to send the message:

"OriginatingHostname"  (1)

Import the hostname of the machine used to send the message:

"OriginatingDate"  (1)

Import the date and time the message was sent:

"OriginatingTimezone"  (1)

Import the client time zone from the mail header:

"ServerOriginatingDate"  (1)

Import the date and time on the originating server:

"ServerOriginatingTimezone"  (1)

Import the time zone of the originating server:

Attachment Elements  (7)

"HasAttachments"  (1)

Determine whether a message has an attachment:

"AttachmentNames"  (1)

Get the file names of any attachments:

"AttachmentList"  (1)

Import attachments as a list of rules:

"AttachmentSummaries"  (1)

Get summaries of the attachments in the email message:

"AttachmentData"  (1)

Import the raw attachment data from the message:

"AttachmentDecodedData"  (1)

Import the decoded attachment data from the message:

"AttachmentDetails"  (1)

Import the attachments and details from the message:

Import Options  (3)

"AttachmentRules"  (3)

Import WAV files as the "Length" element:

Do not import any GIF images:

Specify a pure function to control the import of GIF images: