HCL Domino mail export using iNotes
Since I don’t have a Notes client anymore, I needed a different approach to export some mails from a Domino server.
I couldn’t find anything simple enough that I could use (without having access to either the Domino server or a Notes client), soI built a quick and dirty script to get all the mails I wanted out of that server.
It exploits the “Show Mime Full” action, available in iNotes.
I used a very quick and dirty approach, that includes copying cookies from a browser session into a Python script.
The script loops through the documents based on their Notes Unique ID, and then does a couple of simple changes to the output of the l_MailMessageHeader
Form (notably, remove the <br>
and then un-escape the html), before writing to disk.
url = f"{mailfile}/($All)/{unid}/?OpenDocument&Form=l_MailMessageHeader&PresetFields=FullMessage;1"
response = requests.request("GET", url, cookies=cookies, headers=headers, data=payload, allow_redirects=False)
_mail = response.text.replace("<br>","")
_mail = html.unescape(_mail)
I give the resulting files the .eml
extension, although they’re not strictly eml files.
WARNING : I don’t know the performance impact of the Show Full Mime action on the Domino server, so use caution !
Anyway, these files can be put directly into the data directory structure of Evolution (a Linux mail client). On my Fedora 35 Linux client, that data structure is here:
~/.var/app/org.gnome.Evolution/data/evolution/mail/local/cur
Usage
Basically you just clone the repo and start
git clone https://github.com/Bozzie4/inotes-export
cd inotes-export
Install the python prerequisites (you need Python and pip installed):
pip install -r requirements.txt
Verify it starts:
./main.py -h
You need to get the path to your mailfile, which looks like this:
https://mailserver.company.com/mail/<yourname>.nsf
You need to get the request cookies (for instance, using Developer Tools (use the F12 in any modern browser)), from a logged in session. Using the cookies this way, may or may not work depending on your setup.
You can use the Python script as an example , to include fancier authentication flows.
Copy the complete value of the Cookies
request header.
To export a folder (instead of the default Inbox):
./main.py --mailfile=<path to your mailfile onDomino> --cookie='<the cookie value you copied>' --out-dir="/tmp/export" --mailfolder=TEST
You can also export nested folders, using backslash:
./main.py --mailfile=<path to your mailfile onDomino> --cookie='<the cookie value you copied>' --out-dir="/tmp/export" --mailfolder="Rootfolder\Subfolder"
The resulting “.eml” files can be read directly in Linux mail clients (at least in Evolution).
As long as you use the same out-dir
folder, already downloaded mails will not be downloaded again.