JWBakerIV

Honorable
Jul 1, 2013
1
0
10,510
I'm building an application using a proprietary programming language that is similar to C. The programming language includes a built in send mail function, however it is very limited. I am limited to string sizes of 65535 characters by the language itself. In addition the function does not support sending attachments. The length should never be an issue due to the data I wish to work with, however I would like to be able to send data in the form of a tab-delimited .xls type attached file, as opposed to plain text in the body of the email itself.

To do this the data must be encoded using base64, which I understand and can do without a problem. Ok, So I have my .xls file, it's been converted to base64 and it's ready to send. Now what? If I paste it as is in the message field, I am assuming it will be sent out in it's encoded form as plain text and there will be no mechanism to recognize the data as MIME encoded on the other end and will be jibberish ASCII on the receiving end, and not as an attachment.

Is it possible to include the MIME header information in the actual message field of the email so that the data may be decoded as an attachment on the other end? I'm going to take a wild guess and say no with the little information I can deduce about SMTP protocol. I believe that the attachment data resides outside of the message header, but this is my question. And If so, that means I am unable to transmit attachment data using the built-in send mail function provided by the programming language. In which case I would need to reconstruct the entire SMTP packet by hand to place the encoded data in the correct place with the proper header. The problem is I have not been able to find an SMTP API anywhere so that I can create my own "sendmail" function, which I would love to be able to do. I can manually establish the socket connection to the mail server, I just don't know the format SMTP uses so that I can construct the packets. Can anyone point me in the right direction?
 
Solution
The actual base 64 file is part of the message body. The messgae body can make use of seperators, but it is the SMTP header that tells what the seperator is and what mime type (base64 in this case) to use.

This is an example part of a SMTP header from a message with attachment that I recieved:

Content-Type: multipart/mixed;
boundary="----_=_NextPart_001_01CE523E.A5F4D108"

This boundary/seperator then appears several times throughout the body seperating the plain text, html, and attachment. there is also a mime specification for each part.

See multipart messages:
http://en.wikipedia.org/wiki/MIME

Hawkeye22

Distinguished
Moderator
The actual base 64 file is part of the message body. The messgae body can make use of seperators, but it is the SMTP header that tells what the seperator is and what mime type (base64 in this case) to use.

This is an example part of a SMTP header from a message with attachment that I recieved:

Content-Type: multipart/mixed;
boundary="----_=_NextPart_001_01CE523E.A5F4D108"

This boundary/seperator then appears several times throughout the body seperating the plain text, html, and attachment. there is also a mime specification for each part.

See multipart messages:
http://en.wikipedia.org/wiki/MIME
 
Solution