There are tons of RFC's because it's not that simple.
To embed images and/or attachments in the email message MIME format was created.
MIME is actually a tree structure:
+-multipart/mixed
+-multipart/related
| +-multipart/alternative
| | +-text/plain
| | +-text/html
| +-image/gif
| +-image/jpeg
+-application/x-zip-compressed
+-application/x-zip-compressed
Each multipart mime object consist of one or more parts.
Parts are separated using boundary delimiter.
multipart/mixed -
is used when parts are not related (regular email with attachments)
multipart/related -
is used when pars are related.
For example HTML email that contains images used by this HTML.
(Cid protocol is used in HTML: )
multipart/alternative -
specifies that parts contain same content but in different representations.
For example same text in doc format, html and plain text.
- So first you need to build correct mime structure,
- then encode all mime parts using appropriate encodings (Base64, QuotedPrintable),
- add correct headers to all parts,
- encode them if they contain national or special characters,
- assign boundaries
- and finally render entire message
The main point is this problem has been already solved. Most languages have libraries to create and send emails.
.NET framework has one, not perfect, but still it's probably better that what you'll create.
You can also check out commercial products like Mail.dll email component if you need more control on how the email looks like.