Or you could wrap the contents in [code] ... [/code] tags in the forums here. The results being like this:
For attaching, if the file were on your desktop and you wanted it to have the .txt extension, you could right-click the file, go to rename, and add an extension. Likewise, you could change the filename from the terminal:
This is text
I could have copied and psted this from my menu.lst or any other text file.
And sent it as an attechment, though I can tell you that myself (and most others, I'd reckon) prefer to see the contents of a file inline with a post here, wrapped in CODE tags. It's one less step we have to go through to examine the file.
mv ~/locke/Desktop/myFile ~/locke/Desktop/myFile.txt