You will find the answer in my past post:
Sending HTML attachment with images[
^].
The term "attachment" is very misleading. The files are never "attached" to any mail message. A mail message can be multipart, and some part can be a file coded as base64 text. It has its own part headers, with
content type showing how to process the file, and
context disposition suggesting the mail viewer application what to do with the part. My past answer just explains how to reference a part in another part, as HTML anchor.
See also:
http://en.wikipedia.org/wiki/MIME[
^].
—SA