I'm interested in writing some form letters. I'm a big fan of scrletter2's features, notably placing the "to" address in just the right place for business envelopes.
For the mail merge, I've used datatools package in the past. It's pretty straightforward to use in conjunction with the article class. A MWE might look like
\documentclass{letter}
\usepackage{datatool}
\begin{document}
% load database
\DTLloaddb{scores}{StudentScores.csv}
\DTLforeach{scores}{\firstname=FirstName,\surname=Surname,\score=Score}{%
\begin{letter}{}
\opening{Dear \firstname\ \surname}
Congratulations on your score of \score !
\closing{Yours Sincerely}
\end{letter}
}
\end{document}
However, with scrletter2 things get hairy. Specifically, I'm having trouble figuring out how to place my commands.
I don't know how to post a MWE that's not horrendously long, but here's the gist:
\documentclass[11pt,english]{scrlttr2}
\usepackage{datatool}
\begin{document}
% a bunch of \setkomavar{fromname}{From name} and similar
\DTLloaddb{info}{Book1.csv}
% read database
\DTLforeach{info}{\firstname=FirstName,
\surname=LastName,
\position=Position,}{%
\begin{letter}{\firstname}
Text here
\end{letter}
}
\end{document}
I get the following error:
Runaway argument?
\@nil \@@ {scores}\fi \ifthenelse {\boolean {true}}{\refstepcounter {\ETC.
Paragraph ended before \@dtl@next was complete.
<to be read again>
\par
l.130 }
I feel like something's wrong with the placement of my \DTL commands within the document, but can't figure anything out.
StudentScores.csv
file?