How do I format a text file for IIS Mailroot Pickup so that it sends an e-mail with attachments?
The formatting for files to be read by SMTP can be a little tricky. Be careful with white space and semicolons because the file reader is likely not going to be very forgiving.
Try the following text file, which is a message with 3 attachments. The first attachment is plain ASCII text and will be read as if it is the message body. The other attachments will read as actual file attachments.
From: <[email protected]>
To: <[email protected]>
Subject: Hello World!
MIME-Version: 1.0
Content-Type: multipart/mixed;
boundary="Attached"
--Attached
Content-Type: text/plain;
Content-Transfer-Encoding: 7bit
Hey Scott, I think I've got it figured out. See the attached file.
--Attached
Content-Type: text/plain;
name="TestAttached.txt"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
filename="TestAttached.txt"
VGhpcyBpcyBhbiBleGFtcGxlIG9mIGJhc2U2NCBlbmNvZGVkIHRleHQu
--Attached
Content-Type: text/plain;
name="SourceCode.txt"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
filename="SourceCode.txt"
RnJvbTogPGJtY2Nvcm1hY2tAbXlkb21haW4uY29tPg0KVG86IDxibWNjb3JtYWNrQG15ZG9tYWlu
LmNvbT4NClN1YmplY3Q6IEhlbGxvIFdvcmxkIQ0KTUlNRS1WZXJzaW9uOiAxLjANCkNvbnRlbnQt
VHlwZTogbXVsdGlwYXJ0L21peGVkOw0KICBib3VuZGFyeT0iQXR0YWNoZWQiDQoNCg0KLS1BdHRh
Y2hlZA0KQ29udGVudC1UeXBlOiB0ZXh0L3BsYWluOw0KQ29udGVudC1UcmFuc2Zlci1FbmNvZGlu
ZzogN2JpdA0KDQpIZXkgU2NvdHQsIEkgdGhpbmsgSSd2ZSBnb3QgaXQgZmlndXJlZCBvdXQuICBT
ZWUgdGhlIGF0dGFjaGVkIGZpbGUuDQotLUF0dGFjaGVkDQpDb250ZW50LVR5cGU6IHRleHQvcGxh
aW47DQoJbmFtZT0iYXR0YWNoZWRJbmZvLnR4dCINCkNvbnRlbnQtVHJhbnNmZXItRW5jb2Rpbmc6
IGJhc2U2NA0KQ29udGVudC1EaXNwb3NpdGlvbjogYXR0YWNobWVudDsNCglmaWxlbmFtZT0iYXR0
YWNoZWRJbmZvLnR4dCINCg0KVkdocGN5QnBjeUJoYmlCbGVHRnRjR3hsSUc5bUlHSmhjMlUyTkNC
bGJtTnZaR1ZrSUhSbGVIUXUNCg0KLS1BdHRhY2hlZC0t
--Attached--