emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: "Sébastien Vauban" <wxhgmqzgwmuf-geNee64TY+gS+FvcfC7Uqw@public.gmane.org>
To: emacs-orgmode-mXXj517/zsQ@public.gmane.org
Subject: Mail merge in isodoc class (with datatool... and Org)
Date: Wed, 22 Sep 2010 00:02:15 +0200	[thread overview]
Message-ID: <871v8mhi1k.fsf@mundaneum.com> (raw)

Hi Eric,

Going on within the _tangle_ route, I've managed getting *mail merge* working
from Org, by using the =isodoc= class with the LaTeX package =datatool=.

--8<---------------cut here---------------start------------->8---
#+TITLE:     Org-isodoc
#+AUTHOR:    Seb Vauban
#+DATE:      2010-09-21
#+LANGUAGE:  en_US

* To
  :PROPERTIES:
  :ID:       bfd9e2af-1033-4bf0-a0d1-5757afd9c9a1
  :END:
#+begin_src csv :tangle addresses.csv
FirstName,LastName,Address,PostCode,Town
Albert,ARTHUR,Rue1,1100,Albertville
Beatrice,BENJAMIN,Rue2,2020,Bigard
Christophe,CASTAGNE,Rue3,3003,Calais
Damien,DURAND,Rue4,4440,Dunkerque
#+end_src

* Subject
  :PROPERTIES:
  :ID:       72e05a4c-13b5-48e3-b326-8868a7ab0f09
  :END:
#+srcname: subject
#+begin_src org :results latex
Composing letters using Org mode and the LaTeX isodoc class
#+end_src

* Opening
  :PROPERTIES:
  :ID:       123be106-665b-4da9-9009-769987713f87
  :END:
#+srcname: opening
#+begin_src org :results latex
Dear Org mode users,
#+end_src

* Body
  :PROPERTIES:
  :ID:       3ccb6126-c3d4-4e5f-b630-ef3086d15ca2
  :END:
#+srcname: body
#+begin_src org :results latex
*Problems* encountered /so far/:
- how to insert properly converted tables (to LaTeX)?
  | test | hello |
  | foo  | bar   |
- begin an Org block, editing this code adds commas in front of every line...

That's all for now.
#+end_src

* Closing
  :PROPERTIES:
  :ID:       53486f96-916a-4900-9e01-c27e9661d184
  :END:
#+srcname: closing
#+begin_src org :results latex
Yours Truly
#+end_src

* Encl
  :PROPERTIES:
  :ID:       61870a22-46b7-4446-ab0f-c17ebb36c632
  :END:
#+srcname: encl
#+begin_src org :results latex
I still have to look at how to declare some attached documents.
#+end_src

* Letter
  :PROPERTIES:
  :ID:       b9db447c-0347-414e-a555-edf2ddafdbc3
  :END:
#+begin_src latex :noweb yes :tangle yes
\documentclass[11pt]{isodoc}
\usepackage[utf8x]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{datatool}
\DTLloaddb{addresses}{addresses.csv}

\usepackage{isodoc-style}

\setupdocument{
    subject = {%
      <<subject()>>},
    opening = {%
      <<opening()>>},
    closing = {%
      <<closing()>>}
}

\begin{document}
\DTLforeach{addresses}{%
  \firstname=FirstName,%
  \lastname=LastName,%
  \addressi=Address,%
  \postcode=PostCode,%
  \town=Town%
}{%
\letter[to={\firstname~\lastname\\\addressi\\\postcode~\town}]{%
<<body()>>
}}
\end{document}
#+end_src
--8<---------------cut here---------------end--------------->8---

I'm sure there are other ways, as you said...

>> next step: be able to produce /mail merge/ ("publiposting"), having in Org
>> the list of recipients and the letter's contents -- both in one unique Org
>> file --, and producing all the letters at once (in one PDF), just by =C-c
>> C-v C-e=...
>
> this shouldn't be impossible with the current setup, maybe use sbe to call a
> code block on every row of a table with the table holding the recipients.
> Certainly wouldn't be trivial though.

... but this is a first (working) step!

Comments, patches, ideas, better ways... all are welcome...

Best regards,
  Seb

-- 
Sébastien Vauban


_______________________________________________
Emacs-orgmode mailing list
Please use `Reply All' to send replies to the list.
Emacs-orgmode-mXXj517/zsQ@public.gmane.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode

                 reply	other threads:[~2010-09-21 22:02 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=871v8mhi1k.fsf@mundaneum.com \
    --to=wxhgmqzgwmuf-genee64ty+gs+fvcfc7uqw@public.gmane.org \
    --cc=emacs-orgmode-mXXj517/zsQ@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).