my goal is to create simple new environment. The plan is, to have a box with a simple line frame around it. However, the following code does not work, since LaTeX gives me the following error when trying to compile it.
\framebox is a command that expects the things to be put inside the frame as an argument. You cannot use it that way. With your code, the \framebox command only gets the \textbf token as argument.
You can use the framed package to make frame environments (look into the source code framed.sty for examples):
If you want to mimic the behavior of \framebox, you can use a neat trick from the AMSLaTeX packages to convert environment contents into a macro argument:
Concerning the framed package, a forum search will bring you some threads about it, like this one, from which you can take examples. However, if you plan to use your environment like minipage, try the boxedminipage environment, defined in the boxedminipage package. It behaves like minipage, but with a frame around. It has the same syntax[*]:
where pos is one of usual descriptors t, b or c (the default is c). Other very useful package is fancybox. Its manual provides a short and very instructive course on boxes, with many examples. Surely, one of them may be almost what you need. Don't miss it!
[*] To be precise, minipage has two more optional arguments to control the box height and the internal position of text.
I know that the question is quite old, but for reference:
You can store the whole environment content in a TeX box register (think \savebox und \usebox). This is faster and better then \collect@body, because it doesn't scan the TeX code twice and therefore also allows for verbatim and similar fragile code.
To make this work the plain TeX \setbox is used instead of \savebox to avoid the need for an macro argument.
The temp box \z@ is used here, but any other box defined by \newsavebox works also fine. The \bgroup and \egroup mark the begin and end of the box. The \color@setgroup and \color@endgroup handle some color specific issues.
After saving the box content it can be used as an macro argument as shown
above with