Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

I have an iMac running OS X 10.6.8 and use Apple Mail version 4.5.

I need to access specific parts of specific emails programmatically using Mathematica (others of course could do this more generally with any other programming language, I need to use Mathematica).

I need to find the specific eMails, which I can arrange to identify by either the:

  • "From" and/or
  • "Subject"

fields.

I then need to read either a string of numbers and characters from either the:

  • "Subject" or
  • "Body"

fields of the eMails.

So,

  • Can one do this?
  • If yes, how are emails in Apple Mail kept (flat file, database file, csv, unique format, other)?
  • What is the name of the above file?
  • In what directory can I find it?
  • How do I access the file and the relevant information in the file?

Thanks in advance.

share|improve this question
    
Wht mail server are the mails on as might be easier if an IMAP and possible others to search on there as many languages can use a network protocol to understand them –  Mark Jul 16 '12 at 13:36

2 Answers 2

up vote 1 down vote accepted

One can do this. The following shows what I've found...

Individual Apple Mail emails reside in a directory, typically something like the following:

/Users/UserName/Library/Mail/POP-myEmail@isp.com@pop.secureserver.net/INBOX.mbox/Messages

as ".emix" files readable by any text editor.

".emix" files have a sequential numbering by mails received by one's Apple Mail itself rather than the particular mailbox, something like:

18373.emix
18376.emix
18378.emix

The ".emix" files have clearly marked identifiers of their content. An abridged ".emix" file follows::

Received: (somemailprovider ...); 16 Jul 2012 00:04:00 -0000
Received: from unknown ...; 16 Jul 2012 00:04:00 -0000
X-IronPort-Anti-Spam-Result: AuEPABVXA1DR...
Received: from ....isp.com ...; 15 Jul 2012 17:03:59 -0700
Received: by qcsg1 ...; Sun, 15 Jul 2012 17:03:59 -0700 (PDT)

DKIM-Signature: ...
Received: ...; Sun, 15 Jul 2012 17:03:59 -0700 (PDT)

Return-Path: <myEmail@isp.com>
Received: from iMac-6.local ....

Date: Sun, 15 Jul 2012 20:03:54 -0400 (EDT)
From: myFromEmail@isp.com
To: myToEmail@isp.com
Message-ID: <50035a6e.02d0e00a.1fef.....com>
Subject: TEST
MIME-Version: 1.0
Content-Type: multipart/mixed;boundary="----=_Part_0_1792110529.1342397034510"
X-Nonspam: None

------=_Part_0_...
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit 

------=_Part_0_...
Content-Type: image/gif; name=0001.gif
Content-Transfer-Encoding: base64
Content-Disposition: inline; filename=0001.gif

So, given all of this one needs to:

  • Identify which email one wants to read (I can use date and a specific email directory) ;
  • Import the text of the email into Mathematica;
  • Parse the required information using the appropriate identifiers in the ".emix" file.

A little cumbersome, but workable.

share|improve this answer

There are different paths you could take and to me it seems a bit odd to try to get the information out of the mailapplications data which has probably been saved in an encoded way. If you want to try this, you may find the data in the hidden /Username/Library. You should be able to access it via the Terminal.

Since you're flexible in the kind of language to use, I would highly recommend using Python and then just access the mailserver via imap (or pop3) and search for the information you want that way.

http://docs.python.org/library/imaplib.html#module-imaplib

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.