IIS ASP - CDO.MESSAGE ATTACHMENT

This is Interesting: Free IT Magazines  
Home > Archive > IIS ASP > May 2007 > CDO.MESSAGE ATTACHMENT





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author CDO.MESSAGE ATTACHMENT
rn5a@rediffmail.com

2007-05-19, 1:19 pm

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.

Dave Anderson

2007-05-19, 1:19 pm

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.


rn5a@rediffmail.com

2007-05-19, 7:16 pm

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

Dave Anderson

2007-05-20, 1:20 am

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.


rn5a@rediffmail.com

2007-05-20, 1:20 am

On May 20, 9:44 am, "Dave Anderson" <NPQRWPDWZ...@spammotel.com>
wrote:
> r...@rediffmail.com wrote:
>
> 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.

Dave Anderson

2007-05-20, 1:20 am

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


rn5a@rediffmail.com

2007-05-20, 7:19 am

On May 20, 10:55 am, "Dave Anderson" <NPQRWPDWZ...@spammotel.com>
wrote:
> <r...@rediffmail.com> wrote:
>
> 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

Dave Anderson

2007-05-21, 7:26 pm

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


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


Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com