CDO.MESSAGE ATTACHMENT

CDO.MESSAGE ATTACHMENT

am 19.05.2007 16:55:18 von 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.

Re: CDO.MESSAGE ATTACHMENT

am 19.05.2007 17:17:49 von Dave Anderson

rn5a@rediffmail.com wrote:
> 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.

Re: CDO.MESSAGE ATTACHMENT

am 20.05.2007 00:41:27 von rn5a

On May 19, 8:17 pm, "Dave Anderson"
wrote:
> r...@rediffmail.com wrote:
> > 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?

Re: CDO.MESSAGE ATTACHMENT

am 20.05.2007 06:44:19 von Dave Anderson

rn5a@rediffmail.com wrote:
> But, Dave, how do I write the file to the hard disk of the
> server in the first place?

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.

Re: CDO.MESSAGE ATTACHMENT

am 20.05.2007 07:21:58 von rn5a

On May 20, 9:44 am, "Dave Anderson"
wrote:
> r...@rediffmail.com wrote:
> > But, Dave, how do I write the file to the hard disk of the
> > server in the first place?
>
> 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.

Re: CDO.MESSAGE ATTACHMENT

am 20.05.2007 07:55:51 von Dave Anderson

wrote:
> 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?

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.

Re: CDO.MESSAGE ATTACHMENT

am 20.05.2007 12:40:25 von rn5a

On May 20, 10:55 am, "Dave Anderson"
wrote:
> wrote:
> > 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?
>
> 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

Re: CDO.MESSAGE ATTACHMENT

am 21.05.2007 21:06:57 von Dave Anderson

rn5a@rediffmail.com wrote:
>> ...I store the file and its content-type, filename, etc. in a
>> database...
>
> 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,adP aramInput,16))
CMD.Parameters.Append(CMD.CreateParameter("@Image",adVarBina ry,adParamInput,16))
CMD.Parameters.Append(CMD.CreateParameter("@ContentType",adV arChar,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.


--
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.