ASP cdo email attachment (Full Version)

All Forums >> [Web Development] >> ASP and Database



Message


chobo321321 -> ASP cdo email attachment (11/13/2004 3:28:57)

Hi, I'm trying to create a form where people can upload small files in an email attachment.

For the form I just have 2 textboxes, 1 file browse component, and a submit button. Here's the asp script I'm using. I added the response write statements to see if it grabs the field content which is does, but the file attachment path doesn't inlcude the drive letter in the name.

When I run the script I get the following error which points to the
"objCDOSYSMail.AddAttachment strAttachment" line.

CDO.Message.1 error '800c000d'

<%@LANGUAGE="VBSCRIPT">
<%
'Dimension variables
Dim objCDOSYSCon
Dim strEmail, strWebsite, strAttachment

strEmail = Request.Form("email")
strWebsite = Request.Form("website")
strAttachment = Request.Form("attachment")

Response.Write "From: " & strEmail & "<br />"
Response.Write "From: " & strWebsite & "<br />"
Response.Write "From: " & strAttachment & "<br />"

'Create the e-mail server object
Set objCDOSYSMail = Server.CreateObject("CDO.Message")
Set objCDOSYSCon = Server.CreateObject ("CDO.Configuration")  
'Out going SMTP server
objCDOSYSCon.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "mail.easy-answers.com"
objCDOSYSCon.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
objCDOSYSCon.Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
objCDOSYSCon.Fields("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
objCDOSYSCon.Fields.Update

'Update the CDOSYS Configuration
Set objCDOSYSMail.Configuration = objCDOSYSCon
objCDOSYSMail.From = strEmail
objCDOSYSMail.To = "chobo321321@work.com"
objCDOSYSMail.Subject = "Application Help"
objCDOSYSMail.TextBody = strWebsite
objCDOSYSMail.AddAttachment strAttachment
objCDOSYSMail.Send

'Close the server mail object
Set objCDOSYSMail = Nothing
Set objCDOSYSCon = Nothing
%>




Spooky -> RE: ASP cdo email attachment (11/13/2004 13:40:50)

strAttachment needs to be of the type "c:\folder\file.name", the full path to the file.

eg - depending on the location of the file :
.AddAttachment Server.Mappath(strAttachment )




chobo321321 -> RE: ASP cdo email attachment (11/13/2004 16:41:27)

I added the line, and I get the following error message:

From: chobo@hotmail.com
From: www.test.com
From: testing.htm

CDO.Message.1 error '80070002'

The system cannot find the file specified.

/exp/apply.asp, line 32

I think it is checking for the file on the server, and not my machine. I also have a problem with the following line on the form enctype="multipart/form-data". When I put this line in the form the response.write statements will be blank. Once I take it out it displays whats in those fields.





Spooky -> RE: ASP cdo email attachment (11/13/2004 16:49:46)

Yes, the file needs to exist on your server and be uploaded first.




chobo321321 -> RE: ASP cdo email attachment (11/13/2004 17:04:39)

The form I'm trying to make enables users to browse their computer for a file(graphic one), and send it via email attachment. I'm kinda lost as to how I should go about this.





Spooky -> RE: ASP cdo email attachment (11/14/2004 13:17:08)

Check out something like Lewis Motens uploader from http://www.lewismoten.com/LewiesCodeLibrary/Details.htm?folder=ASP/UploadFilesWithoutCOMv3

Itll enable you to upload the file to the web server so it can be attached.




Page: [1]

Valid CSS!




Forum Software © ASPPlayground.NET Advanced Edition 2.4.5 ANSI
0.046875