Forum Moderators: open
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>
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 :)