About
Shop
LaTeX
Software
Books
Gallery
News
Contact
Blog
Settings
Account
Latest news 2024-12-13: Ebook sale (12th December 2024 – 1st January 2025): cybercrime fiction short stories Unsocial Media and Smile for the Camera free; crime fiction short story The Briefcase free; short story noir crime fiction I’ve Heard the Mermaid Sing free; crime fiction novel The Private Enemy US$1.99; illustrated children’s story The Foolish Hedgehog US$0.99.

Mail Merging (newlfm.cls)

This example requires people.csv and country-codes.csv. Alternatively you can use the samples SQL database.
\documentclass[stdletter]{newlfm}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}

\usepackage[british]{babel}
\usepackage{datatool}

\DTLloaddb{people}{people.csv}
\DTLloaddb{countries}{country-codes.csv}

\newlfmP{orderfromtodate,sigcenter,addrfromphone,addrfromemail}

\namefrom{Mr Big Head}
\addrfrom{University of Somewhere\\Some City\\AB3 4YZ}
\emailfrom{big.head@somewhere.ac.uk}
\phonefrom{0123456789}

\regarding{A sample letter}

\begin{document}

\closeline{Yours sincerely}

\cclist{Prof Important Person\\Dr Bor Ing}

\encllist{Photocopy of something interesting\\
   Photocopy of something rather dull}

\psitem{this is a postscript}

\DTLforeach*{people}% data
{% assignments
  \Id=id,%
  \Surname=surname,%
  \Forenames=forenames,%
  \Title=title,%
  \AddressI=address1,%
  \AddressII=address2,%
  \Town=town,%
  \County=county,%
  \Postcode=postcode,%
  \CountryCode=country%
}
{%
  \xDTLassignfirstmatch{countries}{code}{\CountryCode}{\CountryName=name}

  \nameto{\DTLifnullorempty{\Title}{}{\Title\ }\Forenames\ \Surname}
  \addrto{%
  \AddressI\\
  \DTLifnullorempty{\AddressII}{}{\AddressII\\}\Town\\
  \DTLifnullorempty{\County}{}{\County\\}\Postcode\\\CountryName
  }

  \greetto{Dear \DTLifnullorempty{\Title}{\Forenames}{\Title} \Surname}

  \begin{newlfm}
    This is an imaginary letter.

    This is the second paragraph of the letter.
  \end{newlfm}
}

\end{document}

Download mail-merging-newlfm.tex or mail-merging-newlfm.pdf.

© 2015 Dickimaw Books. "Dickimaw", "Dickimaw Books" and the Dickimaw parrot logo are trademarks. The Dickimaw parrot was painted by Magdalene Pritchett.

Terms of Use Privacy Policy Cookies Site Map FAQs