Email an attachment in ASP

how does ASP email attachments?
Who is Participating?
fritz_the_blankConnect With a Mentor Commented:
Where do the attachments reside--on the server or on the client machine?

If on the client machine, then you will need some ASP code for uploading attachments; ASPUpload is a good one and is available at

On the other hand, if the attachements are on the server, you just add a parameter to your mail code to pick up the attachment. What are you using? CDO, ASPemail, JMail?

Here is an example with ASPemail (available for free at

Set objMail = Server.CreateObject("Persits.MailSender")
     strBody =     "Place your body text here!"

     objMail.Host = ""
     objMail.From = strFromAddress
     objMail.FromName = strFromName
     objMail.AddAddress objRSMailProcess("strEmailAddress")
     objMail.AddAttachment strAttachment 'the path and file name goes here!
     objMail.Subject = strSubject
     objMail.Body = strBody
     On Error Resume Next
     If Err <> 0 Then
        Response.Write "Error encountered: " & Err.Description
     End If                        

Set objMail = nothing
This one's using SMTP Object available in Windows NT and Windows 2000 :

     Dim objCDO
     Set objCDO = Server.CreateObject("CDONTS.Newmail")

     objCDO.To = ""
     objCDO.Cc = ""
     objCDO.From = ""
     objCDO.Subject = "Hi"
     objCDO.Body = "the body of the mail goes here"
     objCDO.AttachFile "c:\"

     set objCDO = nothing

you can use your own variable when using all those properties.

Both of the examples above, however, assume that your attachment resides on the server, not the client machine.

CDO is available only Windows 2000 Server. If you are running Windows NT, the code would be:

dim objMail
set objMail = CreateObject("CDONTS.Newmail")
     objMail.From =
     objMail.To = strEmailAddress  
     objMail.Subject = "Email Request"
     Msg = "This is the first line of your message" & Chr(10)
     Msg = Msg & "This is the second line of your message... and so forth"
     objMail.Body = Msg
        objMail.AttachFile "c:\yourpath\yourfile.ext"
     Set objMail = Nothing
7 new features that'll make your work life better

It’s our mission to create a product that solves the huge challenges you face at work every day. In case you missed it, here are 7 delightful things we've added recently to monday to make it even more awesome.

Good Answer
just remeber to always use absolute path ("C:\..\..\..\myfile.txt") of your file on the server and not relative.
the answer is same as the others but...

if u r using the persist xupload object u can attach files dinamcly.

just upload few files to the x-upload object and then

for each item in xuploadName

I did it in my sites it works
dbnewbieAuthor Commented:
will work on this on the weekend. patience please. thanks.
good luck
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.