Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ASP solution?

Status
Not open for further replies.

Ute

Programmer
Oct 16, 2000
8
0
0
NL
Hello,

On my website I want to make a mailform. A person can enter his name and e-mailadress and some other information. When clicking on the button a mail will be sent to me with the information he entered. That is simple and I have found some ways to realise this. Now I have the following problem.

In the form I can make an input type "file", I found out. But now I want to make it possible for the person to browse his harddisk to find a file he wants to send. That file has to be sent to me as an attachment of the mail. I have found several ways for me to send attachments to other persons, but no ways to for the persons to send attachments to me.

Is there any way to realise what I want? Does anyone have some code-examples for me? Or does anyone know some URLs where I can find some code-examples? I would like those examples in HTML, ASP or JavaScript or maybe Perl. When another cgi-script is used, I want to know where I can download standard scripts, because I have no oppertunity to make them myself.

Thanx in forward.
Greetz, Ute.
 
Hi Ute. This is very possible, and all within ASP as well. You have the break this down into a few different steps. The first one, which you say you have completed, is figuring out how to send mail from your ASP page. Since you didn't specify, I don't know which component you are using, but I will assume that it is a COM object which you are accessing via ASP. I frequently use the CDONTS object with great sucess. The next step is having the user select a file. This is actually a feature that it built in to html 4.0. In your input type, you have to specify that the type="file", and this will allow the suer to select a file on their hard drive.
The next part is the tricky one. Once the user has selected a file, the following has to happen: the file has to be sent to your webserver, saved to the hard drive, attached to an email message, and then sent to you. Uploading a file in ASP is not an easy task. There have been a bunch of commercial COM objects developed that will do just this for you, but I certainly don't like paying for something when you can get it for free. Thus I point you to a wonderful article by Philippe Collignon on ASPtoday at and he outlines how to upload a file using pure VBScript. I suggest you play around with his script for a while, concentrate on getting the upload portion to work first. Since I dont know how you are sending mail from your page, I can't really help you on the attaching the file. Yet all of the components I have encountered have some sort od .attachfile method that allows you to attach a file to the outgoing email. So your page that processes all of the information would retrieve the file, save it to disk, attach it to the outgoing email, and then send it to you. I hope this helps, good luck.

Christopher
 
Well that is another problem. I actually found a way to send mail with ASP, but it didn't work. It was something with a CDONTS object, but something wasn't installed on my computer (the error: "Server.CreateObject failed") , so I couldn't test what I made. I found some things to install what I needed, the error was gone, but it still didn't work.

By the way, I don't know if that what I need for that object is installed on the server where my website will be uploaded to. So maybe solving my problem of sending mail with ASP may not be possible.

Greetz, Ute.
 
Hi Ute,

You can always do a quick check to see if your server supports the CDONTS object. Most NT hosting companies now provide a way to send email using ASP, you should check with your hosting provider. That is, assuming you know where your site is going to be hosted. If you don't, well, that might be a problem :) I am sure there is a way to accomplish what you need via cgi, as that is more widespread, I have never seen a server that did not offer some type of cgi access. However, that is a question for another forum, and it would also involve installing the perl interpreter on your machine, which is a massive download. Sorry I couldn't be of more help.

Christopher
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top