Years ago, there were a variety of incompatible schemes for attaching files to emails. The IETF created a standard for email attachments which is now universally used, not just in email, but in web pages and other places. It is called MIME. It is specified in several RFCs.
MIME
RFC 2045, “Multipurpose Internet Mail Extensions (MIME) Part One: Format of Internet Message Bodies,” November 1996
RFC 2046, “Multipurpose Internet Mail Extensions (MIME) Part Two: Media Types,” November 1996
RFC 2047, “Multipurpose ...