Forum Moderators: open

Message Too Old, No Replies

ASP cdo email attachment

Been trying for days to get this to work...

         

chobo321321

8:27 am on Nov 13, 2004 (gmt 0)

10+ Year Member



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'

View Code

<%@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@example.com"
objCDOSYSMail.Subject = "Application Help"
objCDOSYSMail.TextBody = strWebsite
objCDOSYSMail.AddAttachment strAttachment
objCDOSYSMail.Send

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

[edited by: Xoc at 6:42 pm (utc) on Nov. 15, 2004]
[edit reason] changed to use example.com [/edit]

bateman_ap

1:51 pm on Nov 13, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Try
objCDOSYSMail.AttachFile server.MapPath("attachedfile.zip")