Letter with scrlttr2: How to include adress and text from one single *.tex file

I was wondering, if it is possible using always the same Latex document for writing different letters without copying the whole folder with all the tex files. To begin a new Letter, I want to input one(!) single *.tex file that contains the new adress and(!) the new text. I could solve this issue by using two seperated files - but is ist possible to use just one single file that contains adress and text!?

%%% scrlttr2
\input{praeambel}
\begin{letter}{%
%
}
%%%
\input{text1.tex}
\%input{text2.tex}
%%%
\closing{Sincerely yours}
\end{letter}
\end{document}

\setkomavar{subject}{xxx}
\opening{Dear Mr. xxx}
%%%text

• It sure is possible... You just have to replace the text and the address every time you are writing a new letter. Though I have the feeling that this is not what you have in mind. Could you elaborate what exactly it is you want to accomplish (e.g. your desired "workflow" to write a new letter). – Raven Sep 6 '18 at 9:35
• Do you want a different subject every time? – TeXnician Sep 6 '18 at 10:07
• It is not a bulk letter, where I have a list of people, that receive the same letter. I just wanna "reuse" the format style of the same letter everytime - old letters should be stored in the tex folder. – TRJW Sep 6 '18 at 11:12

Maybe you want:

\begin{filecontents*}{letter1.tex}
\setkomavar{subject}{xxx}
\opening{Dear Mr. xxx}
Text 1
\closing{Sincerely yours}
\end{letter}
\end{filecontents*}

\begin{filecontents*}{letter2.tex}
\setkomavar{subject}{yyy}
\opening{Dear Mr. yyy}
Text 2
\closing{Best regards}
\end{letter}
\end{filecontents*}

\documentclass{scrlttr2}
\begin{document}
\input{letter1}
\input{letter2}
\end{document}


or

\begin{filecontents*}{letterA.tex}
\setkomavar{subject}{xxx}
\opening{Dear Mr. xxx}
Text A
\closing{Sincerely yours}
\end{filecontents*}

\begin{filecontents*}{letterB.tex}
\setkomavar{subject}{yyy}
\opening{Dear Mr. yyy}
Text B
\closing{Best regards}
\end{filecontents*}

\documentclass{scrlttr2}
\begin{document}
\input{letterA}
\end{letter}

\input{letterB}
\end{letter}
\end{document}


If I understand you correctly you want something like a bulk letter, so the following code should suit your needs.

You define the correspondents and the text in the preamble and then it will output the letters for each of the persons. Should you want a different text each time, simply use a fourth argument for \newletter and append it to the sequence. Then use it instead of \tl_use:N \g_trjw_text_tl.

\documentclass{scrlttr2}

\usepackage{xparse}
\ExplSyntaxOn
\seq_new:N \g_trjw_letters_seq
\tl_new:N \g_trjw_text_tl
\NewDocumentCommand { \newletter } { m m m }
{
\seq_gput_right:Nn \g_trjw_letters_seq
{
{#1}, {#2}, {#3}
}
}
\NewDocumentCommand { \settext } { +m }
{
\tl_gset:Nn \g_trjw_text_tl { #1 }
}
\NewDocumentCommand { \typesetletters } { }
{
\seq_map_inline:Nn \g_trjw_letters_seq
{
\seq_set_from_clist:Nn \l_tmpa_seq { ##1 }
\setkomavar { subject } { \seq_item:Nn \l_tmpa_seq { 1 } }
\begin{letter} { \seq_item:Nn \l_tmpa_seq { 2 } }
\opening { Dear ~ Mr. ~ \seq_item:Nn \l_tmpa_seq { 3 } }
\tl_use:N \g_trjw_text_tl
\closing{Sincerely ~ yours}
\end{letter}
}
}
\ExplSyntaxOff