Link to home
Start Free TrialLog in
Avatar of HangTenDesign
HangTenDesign

asked on

CDONTS - "Unspecified error" when trying to attach File

I am getting an unspecified error ....
------------------------------------------
error '80004005'
Unspecified error

/mortgagebanking/admin/rates_savepdf.asp, line 48
------------------------------------------

...while trying to attach a file. The email was sent fine without the Attachment. Here is my code below. I removed private information for this example.


------------------------------------------

Set objMail = Server.CreateObject("CDONTS.NewMail")
objMail.BodyFormat = 0
objMail.MailFormat = 0
 
 objMail.To = "xxxxx@xxxxx.com"
 objMail.From = "xxxxx@xxxxx.com"
 objMail.AttachFile "D:\xxxxx.pdf", "xxxxx.pdf"
 objMail.Subject= "xxxxx"
 objMail.Body = strbody
 objMail.Send
 
------------------------------------------

Thanks for your help!
ASKER CERTIFIED SOLUTION
Avatar of peh803
peh803
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of HangTenDesign
HangTenDesign

ASKER

Interesting. Unfortunately it is against our policy to use the C:\ drive of the web server for this sort of thing. The D:\ drive is mapped to our Documents server from the web server. (Also, we have several scripts that upload files with ASP to the Doc server so it may not be a permissions issue.)

Just to be sure, the AttachFile parameter is relative to the vbscript on the server right? Not relative to the user's local machine.
could you try to attach a text file first?
objMail.AttachFile "c:\aaa.txt"
>>Just to be sure, the AttachFile parameter is relative to the vbscript on the server right? Not relative to the user's local machine.

Yes, it should be.  I understand c:\ access being out of the question from a security perspective... could you try it, though, just as a test to see if this is the problem?  I would not recommend going against security standards, but perhaps it might point you to what the problem is...

Regards,
Phil
then
objMail.AttachFile "D:\aaa.txt"
also make sure the aaa.txt contains some data

>> the AttachFile parameter is relative to the vbscript on the server right? Not relative to the user's local machine
yes, it is running at server side
Also, what authentication do you use to execute this script?  If you use anonymous authentication, you will need to make sure that your IIS anonymous user has access to the mapped share: D:\[whatever]\file_name.pdf directory structure.

Have you looked into this?

Thanks,
Phil
I see the problem
>> objMail.AttachFile "D:\xxxxx.pdf", "xxxxx.pdf"
you need a full path to the file, obviously "xxxxx.pdf" is not
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cdo/html/d3c6df90-b2d2-488d-aeed-de0396f0d7d1.asp

could you try  objMail.AttachFile "D:\xxxxx.pdf"
see if it works?
sorry, never mind above
>>you need a full path to the file, obviously "xxxxx.pdf" is not

I believe the "xxxxx.pdf" (notice that it is the second argument) is just the file name to be used for the attachment (you can alias files if you want to), so this should not actually be the problem.

From your article:

Source (first argument)
Required. IStream object or String. The full path and file name of the file to be attached to the message, or a pointer to an IStream object containing the file data.

FileName  (second argument)
Optional. String. The file name to appear in the attachment's placeholder in the message. If FileName is not supplied, the file name from the Source parameter is used.

Regards,
Phil
I removed the D:\ in the parameter and removed the filename (second) and used a domain address. This worked.
Great -- thanks for sharing the solution!

Glad I was able to help..

Regards,
Phil