1

I need to send a large number of snail mail letters and want to print the addresses/return labels directly on the envelopes. I previously followed this method to make the letters, so already have the addresses in an csv file.

This post then pointed me to the envlab package, and the mlabel command seemed to do exactly what I wanted, but didn't play nicely with the datatools that the first method used for the mail merge.

I then found this method to use the datatools with the letter/envlab packages. But, it is set up to start a letter document, whereas I want to use it for a mlabel command.

I've tried a few options; see code below. If I try the second method with the mlabel command commented out, it will print the address block OK, but not in the envelope format. At least, it means my text commands are OK, but the mlabel function/macro doesn't seem to accept it?

Thanks for any help you can offer. :)

\documentclass{letter}
\usepackage{geometry}
\usepackage{datatool}
\geometry{paperheight=162mm,paperwidth=114mm}
\usepackage[c6envelope,noprintbarcodes,rightenvelopes,printreturnaddress]{envlab}

\makeatletter

\newtoks\address@toks \newcommand\addto@address[1]{% \address@toks=\expandafter{\the\expandafter\address@toks#1}% }

%attempt #1 \newcommand\makeaddress{% \address@toks={}% \addto@address{\firstnamei\ }% \ifthenelse{\DTLiseq{\lastnamei}{}}{}{\addto@address{\lastnamei}} \ifthenelse{\DTLiseq{\firstnameii}{}}{}{\addto@address{& \firstnameii}} \ifthenelse{\DTLiseq{\lastnameii}{}}{}{\addto@address{\lastnameii}} \addto@address{\noexpand\} \ifthenelse{\DTLiseq{\addressi}{}}{}{\addto@address{\addressi\}} \addto@address{\city, \province} \addto@address{\noexpand\} \addto@address{\postal} \begingroup \edef\x{\endgroup\noexpand\mlabel{\the\address@toks}}\x }

%attempt #2 \newcommand\makeaddressii{% \address=\firstnamei\ \ifthenelse{\DTLiseq{\lastnamei}{}}{\relax}{\lastnamei}\ifthenelse{\DTLiseq{\firstnameii}{}}{\relax}{& \firstnameii} \ifthenelse{\DTLiseq{\lastnameii}{}}{\relax}{\lastnameii} \ \ifthenelse{\DTLiseq{\addressi}{}}{\relax}{\addressi\} \city, \province \ \postal \ \mlabel{% my address\someplace\somewhere\}{% \address\}

}

\makeatother

\makelabels \begin{document} \startlabels

\DTLloaddb{addresses}{mail-merge.csv} \DTLforeach*{addresses}{% \firstnamei=FirstName1, \lastnamei=LastName1, \firstnameii=FirstName2, \lastnameii=LastName2, \addressi=Address1, \city=City, \province=Province, \postal=Postal} {%

\makeaddress %attempt#1 \makeaddressii %attempt#2

}

\end{document}

Scott
  • 11

0 Answers0