CDO.MESSAGE ATTACHMENT

R

rn5a

When a user posts a HTML Form in an ASP page, the values entered by
the user in the Form are mailed to the website owner. Users can also
attach a file before posting the Form.

To send the e-mail, I am using CDO.MESSAGE. When I tested the app in
my local intranet IIS5.1 server, the e-mail part worked fine & even
the attachment was sent along with the mail but after deploying the
site at godaddy.com, when I try to send a file from my local hard disk
as an attachment, I get the following error:

===================================
CDO.Message.1 error '80070003'

The system cannot find the path specified.
====================================

which points to the line that does the attachment which is

cdoMessage.AddAttachment Request.Form("uploadfile")

It's pretty obvious what's causing the error - the ASP file resides
onthe server whereas the file to be attached exists in the users local
hard drive but the question is how do I resolve this error?

Please note that users will attach files from their local hard disks.
 
R

rn5a

To send the e-mail, I am using CDO.MESSAGE. When I tested the app in
my local intranet IIS5.1 server, the e-mail part worked fine & even
the attachment was sent along with the mail but after deploying the
site at godaddy.com, when I try to send a file from my local hard disk
as an attachment, I get the following error:
===================================
CDO.Message.1 error '80070003'
The system cannot find the path specified.
====================================

When you attach a file with CDO.Message, you must provide a URL to that file
that the server can access. This is often on the server itself.

In effect, you must have the user UPLOAD the file to be attached, write it
to disk (or database), then provide a URL to either a script that will
retrieve that file[1], or a path to the file.


which points to the line that does the attachment which is
cdoMessage.AddAttachment Request.Form("uploadfile")

RTM:http://msdn2.microsoft.com/en-us/library/ms526983.aspx

[1] While it may be tempting to link directly to the file if written to the
server, IIS6 will not serve it up via http unless specifically configured
for that file's extension.

--
Dave Anderson

Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms.

But, Dave, how do I write the file to the hard disk of the server in
the first place?
 
R

rn5a

Beats me. I stick 'em in a database. You could start here, though:http://www.aspfaq.com/show.asp?id=2189

--
Dave Anderson

Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms.

Dave, by "stick 'em in a database", do you mean populating the
physical path (of the local hard disk of the user) of the file to be
attached? I have already tried that after going through your first
reply but the error persists for obvious reasons. If I upload a file
from C:\MyFolder\MyFile.doc from my local machine, then it will be
stored in the database as C:\MyFolder\MyFile.doc but there's no file
named MyFile.doc within any directory named MyFolder in the C:\ drive
of the server; so how will the server upload the file?

Pardon me if I have misinterpreted your database suggestion.
 
R

rn5a

No. I mean I store the file and its content-type, filename, etc. in a
database. I have done it with SQL Server 2000 and 2005. The SQL Server data
type for storing arbitrary binary data (which you will need for files) is
"Image".

--
Dave Anderson

Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms.

Ooops....I completely got it wrong! Sorry......

Dave, could you please link me to some articles on how did you do that
or show a small code snippet?

Thanks,

Regards,

Arpan
 
D

Dave Anderson

Dave, could you please link me to some articles on how did you
do that or show a small code snippet?

In classic ASP, we do everything in JScript, and there is no simple or
efficient pure ASP/JScript way of doing it, so in the past, we used a
component. In our case, we bought a copy of Fath Upload
(http://www.fathsoft.com/upload.html) for the simple reason that it allowed
us access to the data stream -- and thus made direct database inserts
straightforward. A simplified example, from a script with which we attach an
image to a classified ad:

var UP = Server.CreateObject("Fath.Upload"),
CN = Server.CreateObject("ADODB.Connection"),
CMD = Server.CreateObject("ADODB.Command")

CN.Open(myConnectionString)
CMD.ActiveConnection = CN
CMD.CommandType = adCmdStoredProc

UP.Receive("")

CMD.CommandText = "myStoredProcedureName"
CMD.Parameters.Append(CMD.CreateParameter("@GUID",adGUID,adParamInput,16))
CMD.Parameters.Append(CMD.CreateParameter("@Image",adVarBinary,adParamInput,16))
CMD.Parameters.Append(CMD.CreateParameter("@ContentType",adVarChar,adParamInput,50))
CMD.Parameters("@GUID").Value = UP.Field("AdGUID").Value
CMD.Parameters("@Image").Size = UP.File("AdImage").Size
CMD.Parameters("@Image").Value = UP.File("AdImage").GetChunk(0,Size)
CMD.Parameters("@ContentType").Value = UP.File("AdImage").ContentType
CMD.Execute()


It has become ridiculously easy -- not to mention free and likely to be
around in the future -- with ASP.NET 2.0, so we have moved away from doing
uploads with classic ASP.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,821
Latest member
AleidaSchi

Latest Threads

Top