Forum Moderators: open

Message Too Old, No Replies

How ASP AttachFile works?

         

Maria

7:35 pm on Jan 31, 2003 (gmt 0)

10+ Year Member



Hello everyone;
I am trying to send a attachment from a ASP form, and I want the people to be able to select the file from their computers.

Why when I am using this code works?
file="C:\test.txt"
filename = "filename.txt"
objCDOMail.AttachFile file , filename

and with this one I get an error.
file = request.form("file1") ' this is a Input type=file entry
filename = "filename.txt"
objCDOMail.AttachFile file , filename

If there is another way to do it, please let me know.
I appreciated any help.

This is the complete code:

strFrom = "mariaelisau@hotmail.com"
strTo = Request.Form("email")
strSubject = "Testing"
strBody = "epa"
file="C:\test.txt"
'file = request.form("file1")
filename = "filename.txt"
Set objCDOMail = Server.CreateObject("CDONTS.NewMail")

objCDOMail.From = StrFrom
objCDOMail.To = strTo
objCDOMail.Subject = strSubject
objCDOMail.Body = strBody

objCDOMail.AttachFile file , filename
objCDOMail.Send
Set objCDOMail = Nothing
%>

<html>
<body>
<form METHOD="POST" ACTION="sendemail.asp">
<input TYPE="FILE" NAME="file1" size="60"><p>
<input type="text" name="email" size="30"><br>
<input TYPE="SUBMIT" VALUE="Upload!"></p>
</form>
</body>
</html>

aspdaddy

8:24 pm on Jan 31, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



This has been posted before, the problem is the upload not the attach.

It works when you test because the file does not have to be uploaded - its already on the server.

The code will not upload a file, you have to use a component or binary read it.

There is a script called pure asp upload that works well for small files, else try ASPUpload -component.

And welcome to webmasterworld :)

Maria

8:58 pm on Jan 31, 2003 (gmt 0)

10+ Year Member



Thank you ASPdaddy;

I am going to try and I will let you know.

Again, thank you very much for your help.

Maria