Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CDONTS attach

Status
Not open for further replies.

cjkenworthy

Programmer
Sep 13, 2002
237
0
0
GB
I am sending an email and attaching a file using straight forward CDO. The email sends ok, as I recieve it - but the attached file, despite having the correct name, is unreadable and is always the same size (78 bytes). (If opened in notepad the file is empty)

I have tried different filenames, locations etc... The file itself is readable and I can access it in windows explorer as a standard file. I have set the anonymous account to have read/write permissions on the directory where the file resides.

Why is it not attaching the actual file?

Cheers.

CODE:

(The Server MapPath gives: c:\inetpub\ - Which is correct

Dim MyCDONTSMail
Dim HTML
Set MyCDONTSMail = CreateObject("CDONTS.NewMail")

MyCDONTSMail.AttachFile(Server.MapPath("claim_data/" & Filename))

HTML = &quot;<html> etc ...&quot;

MyCDONTSMail.From=&quot;system@mydomain.com&quot;

MyCDONTSMail.To=&quot;myaddress@mydomain.com&quot;
MyCDONTSMail.Subject=&quot;Data File&quot;
MyCDONTSMail.BodyFormat=0
MyCDONTSMail.MailFormat=0
MyCDONTSMail.Body=HTML
MyCDONTSMail.Send
set MyCDONTSMail=nothing
 
Hello cjkenworthy

Have you tried sending a ZIP file? I think the problem is that most E-mail systems tend to open the TEXT file attachment and instead of an attachment it becomes part of the email. You can even see it appended to the end of the email.

I have had this problem when sending even ASP/HTML pages via email. So now I ZIP them all.

Regards
Satishkumar
 
you can try taking the servermap part out of the code and putting the actual name of the file between the brackets. Works for me no problems.

Code
objCDONTS.AttachFile Server.MapPath(&quot;welcome.doc&quot;)


ltleforge
 
Hi everyone, thanks for your help.

As it turns out it is something to do with the encoding of the email and the mail format:

MyCDONTSMail.BodyFormat=0
MyCDONTSMail.MailFormat=0

as you change the parameters of these two (0/1) it changes the encoding - meaning you can no longer have HTML CDONT mail - but the attachments work. I found it is best to leave both commented out, which gives a plain text email but the attachment works. For more information see:

 
Hi there,

I am facing the same problem. One thing I have noticed is that small attachments (< 100 kb) are fine but larger ones come as 64 bytes empty attachment files.
Please help.

Thanks
-rb79
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top