0

I'm trying to use the mailmerge package with the KOMA scrlttr2 letter class, but it is failing with a There's no line here to end. message, presumably because the address field is rendering as blank. I expect I am making some elementary mistake. Sample code follows:

\documentclass[foldmarks=false,backaddress=false,
fromalign=false,version=last]{scrlttr2}
\usepackage{fouriernc}
\usepackage[T1]{fontenc}
\usepackage{mailmerge}
\begin{document}
\setkomavar{fromname}{H. G. Wells}
\setkomavar{fromaddress}{Spade House\\ 5281 Radnor Cliff Crescent (West Side)\\ Sandgate, Kent}
\mailfields{address}
\def\today{1st January, 1895}
\begin{letter}{
    % George Bernard Shaw,\\
    % Shaw's Corner,\\
    % Bibbs Hall Lane,\\
    % Ayot St. Lawrence, Hertfordshire\\
    \mailrepeat{\field{address}}
  }

\opening{Dear Shaw,}

You suck!

\closing{Sincerely}
\end{letter}

\mailentry{GBS}

\end{document}
Faheem Mitha
  • 7,778
  • Are you bound to the mailmerge package? If not, you may want to try the datatoolpackage instead. Please see this sample code (http://tex.stackexchange.com/questions/203918/latex-document-containing-csv-data-with-empty-fields/204111#204111) from Nicola Talbot. It works like a charm with scrlttr2. – blue_tiger300 Jun 12 '15 at 05:39
  • @blue_tiger300 I use datatool, yes. But mailmerge seems nice and simple, and ideally customized for this purpose. datatool, dunno. Not so much. – Faheem Mitha Jun 12 '15 at 05:44
  • @FaheemMitha also textmerg is nice and simple. Please see http://tex.stackexchange.com/a/89803/11604 – Fran Jun 12 '15 at 06:30
  • @Fran thanks for the tip. Do you have any thoughts on the differences between mailmerge and textmerg? – Faheem Mitha Jun 12 '15 at 06:40
  • @FaheemMitha Sorry, beside that I used one or two times textmerg but never mailmerge, I have not comparative thoughts about these packages. – Fran Jun 12 '15 at 22:01

1 Answers1

1

You aren't using \mailrepeat correctly. Its argument should be the text that you want to repeat, which is not the address but the whole letter:

\documentclass[foldmarks=false,backaddress=false,
fromalign=false,version=last]{scrlttr2}
\usepackage{fouriernc}
\usepackage[T1]{fontenc}
\usepackage{mailmerge}
\begin{document}
\setkomavar{fromname}{H. G. Wells}
\setkomavar{fromaddress}{Spade House\\ 5281 Radnor Cliff Crescent (West Side)\\ Sandgate, Kent}
\mailfields{address}
\def\today{1st January, 1895}

\mailrepeat{
  \begin{letter}{
    % George Bernard Shaw,\\
    % Shaw's Corner,\\
    % Bibbs Hall Lane,\\
    % Ayot St. Lawrence, Hertfordshire\\
    \field{address}
  }

  \opening{Dear Shaw,}

  You suck!

  \closing{Sincerely}
  \end{letter}}

\mailentry{GBS}

\end{document}
Ulrike Fischer
  • 327,261