Mailing an Attachment with CDO
If you're coding in ASP, you often are using it to mail out messages, including attachments. This can be a great way to share files with your visitors.
The syntax is very straightforward. In a form, you request the email address of the user. Then in your processing script, you would use:
Email = request("email")
Set objMail= Server.CreateObject("CDO.Message")
With objMail
.From = "webmaster@yoursite.com"
.To = Email
.Subject = "File You Requested from SiteName"
.TextBody = "Here is the file you requested from SiteName"
.AddAttachment "C:\files\filename.pdf"
.Send
End With
Set objMail = Nothing
==========================
The beauty of this is that the actual file location - the c:\files\ - is NOT on the web anywhere. That directory is completely separate from your web directories. That means no web surfer anywhere can get to these files. Only the people who use your online forms can have the files sent to them. That gives you some level of security, that only people who should see the files can get them.
However, keep in mind that as soon as a user gets their hands on a file, they could easily forward it to friends. But you can't really help that. At some point you need to realize that if a user can see a file, they can steal it if they want to. Heck, people scan entire books into their computers sometimes (i.e. Harry Potter) to share with friends. So at some point you have to accept that you've done the best you can as far as protecting your files. If someone goes through the effort to steal your work at that point, it is out of your hands.
Just make sure that the sent file is well branded with your site name and information, so at least the file itself always indicates where it came from!
ASP Mail Code and Troubleshooting