CLOSED: [2016-12-23 Fri 17:18] SCHEDULED: <2016-12-23 Fri> :PROPERTIES: :CREATED: [2016-12-22 Thu 11:18] :ID: 2016-12-22-email-to-orgmode :END: :LOGBOOK: - State "DONE" from "DONE" [2017-03-17 Fri 11:30] - State "DONE" from "NEXT" [2016-12-23 Fri 17:18] :END: Update 2017-03-17: Link to the method of Sam Flint Silent update 2019-09-25: added to [[id:2019-09-25-using-orgmode][blog series "Using Org Mode Features"]] Please do read [[id:2019-09-25-using-orgmode][my "Using Org Mode Features" (UOMF) series page]] for explanations on articles of this series. This article is for [[id:tags-emacs][Org-mode]] users who are looking for a possibility to get emails into org-mode which is independent of their email client ([[https://en.wikipedia.org/wiki/Email_client][MUA]]). You're going to need access to your mail server for this method. From time to time, I get tasks by email where the email body contains helpful information on that task. Therefore, it is nice to have a method that gets the email header and body into my Org-mode system. -------------------- I do not use an Emacs-based mail setup, which would make this task an easy one depending on your MUA solution. Therefore, I created a workaround by bouncing relevant emails to a special email address I use for forwarding emails to Org-mode: =orgmode@MY-DOMAIN.AT= I am maintaining my own email server and I am (still) using [[https://en.wikipedia.org/wiki/Procmail][procmail]] to filter/preprocess emails. Please start with [[http://mailfilter.sourceforge.net/][mailfilter]] instead if you do a fresh start. In contrast to good old procmail, mailfilter is maintained and offers a modern interface. So when I receive a new email to that specific email address the following procmail filter rule matches: : :0 : * ^(Resent-To|X-Original-To|To|Bcc|Cc): orgmode@MY-DOMAIN.AT : { : :0 : |/home/karl/src/vk-add-email-to-org.sh : } The filter rule pipes the email into the shell script =vk-add-email-to-org.sh= which looks like this: : #!/bin/sh : : ## generates an org-file-entry from the email sent through stdin : : ORGFILE="/home/karl/org/inbox.org" : : ## build email by adding input from stdin line by line: : while IFS= read -r line : do : email="${email} : ${line}" : done : : ## extract header information: : subject=`echo "${email}"|formail -x "Subject"` : header=`echo "${email}"|formail -X "From" -X "Subject" -X "Date" -X "Message-ID" -X "To"` : body=`echo "${email}"| sed -e '1,/^$/ d'` : : ## append mail header and body as new TODO heading to ORGFILE: : echo "* TODO Email:"${subject} >> ${ORGFILE} : echo >> ${ORGFILE} : echo "#+BEGIN_QUOTE" >> ${ORGFILE} : echo "${header}" >> ${ORGFILE} : echo "#+END_QUOTE" >> ${ORGFILE} : echo >> ${ORGFILE} Since all my computers have a synchronized version of my Org-mode files, the mail information is appended to my current Org-mode inbox file. This is the same file I use for getting in stuff from [[http://orgmode.org/manual/MobileOrg.html][MobileOrg]]. Refiling from =inbox.org= is the same process as refiling my input from MobileOrg which I do on a daily basis. So maybe this is also a handy workflow for you as well. I do like it because it is completely independent of my mail client and the hosts I am working on. Please drop me an email or comment below when you do have remarks or found similar methods. *** Sam Flint [[http://samflint.com/about-me.html][Sam Flint]] published [[http://samflint.com/capture-with-email.html][his version of the same workflow]] that is using fetchmail, procmail, ripMIME and Pandoc. It is an extended and more elaborated version of my workflow.