homepage Welcome to WebmasterWorld Guest from 54.237.95.6
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor
Visit PubCon.com
Home / Forums Index / Microsoft / Microsoft IIS Web Server and ASP.NET
Forum Library, Charter, Moderators: ocean10000

Microsoft IIS Web Server and ASP.NET Forum

    
Trying to AddAttachment
Help needed trying to AddAttachment using CDO object
michael11




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

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

 

martyt




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

Try the AttachFile method instead.

michael11




msg:949992
 6:42 pm on Feb 24, 2005 (gmt 0)

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

Easy_Coder




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

Try like this:
objMessage.AddAttachment("file://C:\temp\sample.txt")

michael11




msg:949994
 7:25 pm on Feb 24, 2005 (gmt 0)

tried that suggestion, but now getting 'system cannot find the path specified' The path is right and the file is there

Easy_Coder




msg:949995
 1:58 pm on Feb 25, 2005 (gmt 0)

You've got something else going on then; I got that right from the msdn.

michael11




msg:949996
 2:43 pm on Feb 25, 2005 (gmt 0)

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?

martyt




msg:949997
 3:45 pm on Feb 25, 2005 (gmt 0)

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.

Easy_Coder




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

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.

michael11




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

thanks guys

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Microsoft / Microsoft IIS Web Server and ASP.NET
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About
© Webmaster World 1996-2014 all rights reserved