Link to home
Start Free TrialLog in
Avatar of lingamgr
lingamgr

asked on

file attachment using CDONTS mail object

Can I attach a dynamic file after accepting the user's choice, using CDONTS.AttachFile property. i.e.

CDONTS.AttachFile &filename where &filename is the variable name.Is the syntax correct ?

Secondly, the attached file goes and gets appended to the body message of the email. Can I send a file as an true attachment i.e. user has to click attach button of email to view the attachment.  If this is not possible, is there any other way that I can send a file as an true attachment file ( without appending the body message )
Avatar of webwoman
webwoman

Not a file from the CLIENT -- you don't have any access to the client system. CDONTS runs on the SERVER, not the client.

If you have a file on the server you want to attach, you can do it there. NOT anything on the client.
ASKER CERTIFIED SOLUTION
Avatar of heusto
heusto

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 lingamgr

ASKER

Dear Expert Heusto,

I would like to thank you for your good solution to 2nd part my question. i.e. attaching a file using AttachFile property of CDONTS property.

But my 1st Part of Question was, is it possible to attach a file dynamically from server.  Because I have to attach frequently files from server when I send a email.

syntax problem was:

CDONTS.AttachFile "c:\directoryname\filename"
but I want to use with variable like

CDONTS.Attach File &variablename (variable name for filename)

If possible please give me solution with proper syntax
 
with kind regards
g.r.lingam
You are almost there. I have included some code just to make sure...


dim sCDONTS
dim sFilename

sFilename = request.querystring("filepath")

set oCDONTS = server.createobject("CDONTS.NewMail")

oCDONTS.to = "someone@somewhere"
oCDONTS.From = "me@work"
oCDONTS.Subject = "File attached"
oCDONTS.AttachFile sFilename

oCDONTS.Send

set oCDONTS = nothing


this should work.
Dear heusto,

perfect solution. I would like to thank you for your syntax for attaching files dynamically.  All along, I was trying with &variablename.  Without & sign, I am able to attach files dynamically. Thank you very much.

I would like to raise one more doubt. Whether we would be able to attach files from other directories of server. i.e. could we use physical path, using

sFileName = request.querystring("c:\somedirectory\file1")
msCDONTs.AttachFile Server.MapPath sFileName

Is the above syntax correct?

Please clarify..

with kind regards
g.r.lingam
Dear heusto,

I have done the job.  I could attach file from other directories of server.  Thank you very much for your co-ordination.

with kind regards,
g.r.lingam
attaching text file using AttachFile property of CDONTS mail proper does work well.  Whereas when I send word file or excel file i.e. filename.doc or filename.xls, the file is being viewed at the receiptent in jumpled manner.
Is it possible to attach files of any type of files or only text and html files.

looking forward to your clarification

with kind regards
g.r.lingam
as far as I can remember it is possible to send any file types.

Can't vouch for the mail servers inbetween though.