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}
  • Are you bound to the mailmerge package? If not, you may want to try the datatoolpackage instead. Please see this sample code (tex.stackexchange.com/questions/203918/…) from Nicola Talbot. It works like a charm with scrlttr2. – blue_tiger300 Jun 12 '15 at 5: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 5:44
  • @FaheemMitha also textmerg is nice and simple. Please see tex.stackexchange.com/a/89803/11604 – Fran Jun 12 '15 at 6:30
  • @Fran thanks for the tip. Do you have any thoughts on the differences between mailmerge and textmerg? – Faheem Mitha Jun 12 '15 at 6: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

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}
  • Thank you for the explanation, Ulrike. Indeed, it was a foolish mistake, as I thought. – Faheem Mitha Jun 14 '15 at 3:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.