Page 1 of 1

Sendmail with attached file

Posted: Fri May 09, 2003 10:39 pm
by Cantor
Hi!

Is there a possibilty to use the sendmail-procedure (resources site) to send a mail with an attached file? The sendmail procedure only sends the message subject and the message body.

--
Greetings, Martin.

Posted: Fri May 09, 2003 10:59 pm
by Mr Skunk
Yes, you can use the Base64Encoder() function to add everything to your mails bodies. Attachements are just Base64 (or other) encoded files directely included as ascii in your mail body.

You will also need to use the multipart/mixed content type, and Boundary to build your mail.
Any mailler can show you the source of a mail, look at a source with an attachment to really see how to use multipart/mixed content type and Boundary (not very complicated).

Posted: Sat May 10, 2003 12:39 am
by ShDancer
Another thing.

Its true that i can use Base64 to encode, but how can i read an encoded mail with an attatchment?

Thanks...

Posted: Sat May 10, 2003 12:48 am
by freak
@ShDancer:

Have a look here:
viewtopic.php?t=4970&highlight=base64decoder

Timo

Posted: Sat May 10, 2003 12:55 am
by ShDancer
freak wrote:@ShDancer:

Have a look here:
viewtopic.php?t=4970&highlight=base64decoder

Timo
Doh, i've seen it allready and forgot about it :oops:

Thanks.

Posted: Sat May 10, 2003 11:02 am
by Cantor
Mr Skunk wrote:Yes, you can use the Base64Encoder() function to add everything to your mails bodies. Attachements are just Base64 (or other) encoded files directely included as ascii in your mail body.
Thank You For Your answer.
Can You perhaps give an example how to code this? It's difficult for me to understand how the Base64Encoder() works with files.

--
Greetings,
Martin.

Re: Sendmail with attached file

Posted: Sat May 10, 2003 11:14 am
by PB
I saw a lot of conflicting stories about sending mail with attachments, so in
the end I just downloaded "Blat" (a command line mailer) and included it in
my app as a binary. I can then send mail using the RunProgram command.
You can download it from here:

http://www.interlog.com/~tcharron/blat.html

It is totally legal to use Blat in your own apps this way as it has been placed
in the Public Domain and its own docs state (in part): "you can use it free
of charge for any purpose you like [...] You have permission to modify,
redistribute, hoard, or even sell Blat in its executable or source form [...]"

Just remember to compress its exe before IncludeBinary'ing it into your app,
to keep the inclusion small. (It's not that large, anyway). Also, it's a good
idea to rename it from Blat.exe to YourApp.exe so that any firewalls will
refer to it by your app's name, so that your users don't panic and wonder
why an app called "Blat.exe" is trying to access the Internet. :)

Maybe one day someone will post some good (working) sendmail code to
these forums, that supports attachments, so Blat doesn't have to be used.