How do I need to format a text file so that it can be read by an SMTP service to send an e-mail that has an attachment?
We have a server where we are using
II6 SMTP to send mail from a Pickup folder. The goal is to drop a properly formatted text file into Mailroot\Pickup and then the file will be automatically processed and sent to the correct SMTP recipient.
For simple files, this works correctly. Here's an example of a simple file that works (domain names changed):
From:
[email protected]
To:
[email protected]
Subject:Hello World!
Test Body Of The E-mail
When I drop a text file containing the above contents into the Mailroot\Pickup folder, it sends correctly. However, I haven't been able to figure out how to get an attachment to work.
I found some material that explained how to encode an SMTP attachment and another tool for simple base64 encoding conversion. Using the information on those pages, I came up with the following text:
From:
[email protected]
To:
[email protected]
Subject:Hello World!
MIME-Version: 1.0
Content-Type: text/plain;
boundary="Attached"
Content-Disposition: inline;
--Attached
Content-Transfer-Encoding: base64
Content-Type: text/plain;
name="attachment.txt"
Content-Disposition: attachment;
filenamename="attachment.txt"
VGhpcyBpcyBhIHRlc3Qgb2Ygc29tZXRoaW5nIHRvIGVuY29kZS4NCk5ldyBsaW5lDQpOZXcgTGlu
ZQ0KIkhlbGxvdyIgISEhDQo9PT09ICcgZnNkZnNkZiAxMjM1NDU2MzQzNA==
--Attached--
However, when I place the above text in a file and drop it into Mailroot\Pickup, it doesn't send an attachment correctly. Instead, an e-mail shows up with the following in the body of the e-mail:
MIME-Version: 1.0
Content-Type: text/plain;
boundary="Attached"
Content-Disposition: inline;
--Attached
Content-Transfer-Encoding: base64
Content-Type: text/plain;
name="attachment.txt"
Content-Disposition: attachment;
filenamename="attachment.txt"
VGhpcyBpcyBhIHRlc3Qgb2Ygc29tZXRoaW5nIHRvIGVuY29kZS4NCk5ldyBsaW5lDQpOZXcgTGlu
ZQ0KIkhlbGxvdyIgISEhDQo9PT09ICcgZnNkZnNkZiAxMjM1NDU2MzQzNA==
--Attached--
I can't figure out what I need to do to format the text file so that the SMTP service correctly sends attachments.