Welcome to WebmasterWorld Guest from 54.204.165.156

Forum Moderators: ocean10000

Trying to AddAttachment

Help needed trying to AddAttachment using CDO object

   
4:47 pm on Feb 24, 2005 (gmt 0)

10+ Year Member



Hello - Sorry if this isn't the right place to post this. I'm trying to add an attachment to an email using vbscript and the CDO object. Everything works ok until I tried to add an attachment. I get the following error:

CDO.Message.1 error '80070003'
The system cannot find the path specified.

Now I know that the file exists and that the path specified is correct. Checked 100 times. I've hardcoded the file path in the AddAttachment. Any help on what could be going on would be great. Thank You. Here is my code:

<!--METADATA TYPE="typelib" UUID="CD000000-8B95-11D1-82DB-00C04FB1625D" NAME="CDO for Windows Library" -->

<!--METADATA TYPE="typelib" UUID="00000205-0000-0010-8000-00AA006D2EA4" NAME="ADODB Type Library" -->
<%
Dim objConfig ' As CDO.Configuration
Dim objMessage ' As CDO.Message
Dim Fields ' As ADODB.Fields

Set objConfig = Server.CreateObject("CDO.Configuration")
Set Fields = objConfig.Fields

With Fields
.Item(cdoSendUsingMethod) = cdoSendUsingPort
.Item(cdoSMTPServer) = "#*$!#*$!xxxxx"
.Item(cdoSMTPServerPort) = 25
.Item(cdoSMTPConnectionTimeout) = 10
.Update
End With

Set objMessage = Server.CreateObject("CDO.Message")

Set objMessage.Configuration = objConfig

' thisEmail = "xxx@xxxx.orgx"
thisEmail = "xxxxx@xxxxx.com"

bodyContent = "<html>xxxxxxxxxxxx</html>"

With objMessage
.To = thisEmail
.From = "xxxxx@xxxxx.com"
.Subject = "xxxxxxxxxx"
.HTMLBody = bodyContent
.AddAttachment "c:\xxxxx\xxxxx.txt"
.Send
End With

Set Fields = Nothing
Set objMessage = Nothing
Set objConfig = Nothing
%>

5:49 pm on Feb 24, 2005 (gmt 0)

10+ Year Member



Try the AttachFile method instead.
6:42 pm on Feb 24, 2005 (gmt 0)

10+ Year Member



I tried your suggestion, now I'm getting:

Microsoft VBScript runtime error '800a01b6'
Object doesn't support this property or method: 'AttachFile'

Any other thoughts

7:05 pm on Feb 24, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Try like this:
objMessage.AddAttachment("file://C:\temp\sample.txt")
7:25 pm on Feb 24, 2005 (gmt 0)

10+ Year Member



tried that suggestion, but now getting 'system cannot find the path specified' The path is right and the file is there
1:58 pm on Feb 25, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You've got something else going on then; I got that right from the msdn.
2:43 pm on Feb 25, 2005 (gmt 0)

10+ Year Member



Thanks Easy_Coder and martyt. The attachment does work, but only when I'm attaching a file from the server. I'm having people fill out a form and then want them to attach a file from their local hard drive. Is that possible?
3:45 pm on Feb 25, 2005 (gmt 0)

10+ Year Member



The attachment does work, but only when I'm attaching a file from the server. I'm having people fill out a form and then want them to attach a file from their local hard drive.

Ohhhh.... That's completely different!

The ASP code you've written is running on the *web server*, not the user's machine. So of course there's no file in the path the user is specifying.

You'll probably need to upload the user's file to a temporary location on the web server, then attach that temporary file to the e-mail, then delete the file from the temporary location. There might be a more direct way to do it - I haven't tried.

First order of business is to find code for uploading a file from the user's machine - shouldn't be hard to find. You'll need to make sure you have the proper permissions set on the destination directory on the server - which may take a call to your hosting provider.

After that it should be fairly straightforward.

5:53 pm on Feb 25, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



In addition to what martyt said...

Ask your host what kind of file upload components are available on the server OR you can roll your own solution with .net.

7:40 pm on Feb 25, 2005 (gmt 0)

10+ Year Member



thanks guys
 

Featured Threads

Hot Threads This Week

Hot Threads This Month