Attaching a file to an email asp page

Posted on 2006-04-17
Last Modified: 2009-12-16
Hi All!

So... I've got a questionnaire form working properly at

I would like to add a field for the user to upload an attachment. That part is easy enough to do in the HTML page.

How can I get the file (resume) to be included in the email that is generated by the asp file? Can it be attached somehow?

Placing ENCTYPE= in the form tag of the HTML page borks up the ASP response page with a CDO error.

The asp code i'm using is seemingly pretty basic. I'm no asp guru, so I'm pretty much stuck here.

the code is as follows:


q1= Request("q1")
q2= Request("q2")
q3= Request("q3")
q4= Request("q4")
q5= Request("q5")
q6= Request("q6")
q7= Request("q7")
q8= Request("q8")
q9= Request("q9")
q10= Request("q10")
q11= Request("q11")

If q6 = "Yes" then
mailSubject="Employment Opp High "
mailSubject="Employment Opp Medium "
end if
'--------------------------------------- EMAIL FORMAT -----------------------------

Dim MyMail
Set MyMail = Server.CreateObject("CDO.Message")
Set iConf = CreateObject("CDO.Configuration")
Set Flds = iConf.Fields

body = "<b>Name:</b> "& q1 &"<br>"
body = body & "<b>Email:</b> "& q2 &"<br>"
body = body & "<b>Phone:</b> "& q3 &"<br>"
body = body & "<b>City:</b> "& q4 &"<br>"
body = body & "<b>State:</b> "& q5 &"<br>"
body = body & "<b>If offered a management position with our company are you willing to relocate?:</b> "& q6 &"<br>"
body = body & "<b>Please gives us a description of your personal work history from childhood and explain why you think you would make a valuable addition to our team:</b> "& q7 &"<br>"
body = body & "<b>How many months have you been conducting your current employment search?:</b> "& q8 &"<br>"
body = body & "<b>How many employment opportunities have you submitted your resume for during this time?:</b> "& q9 &"<br>"
body = body & "<b>Please describe what you feel to be your greatest accomplishment in 500 words or less:</b> "& q10 &"<br>"
body = body & "<b>I would like to schedule a telephone interview:</b> "& q11 &"<br>"

With Flds
' assume constants are defined within script file
.Item("") = 2
.Item("") = ""
End With
With MyMail
Set .Configuration = iConf
.To = ""
.From = q2
.Subject = mailSubject
.HTMLBody = body

End With

Set MyMail = Nothing


Again, I can add the field to upload a file, which you can see at the bottom of , but I cannot get that file to show up in the emaqil sent with the above code. Granted, I've not actually added anything to the ASP code since adding the FILE field to the form. I simply dont know what to do.



Question by:jimbonics
    1 Comment
    LVL 1

    Accepted Solution


    Add the following line within With ... End With block to attach a file:

    With MyMail
           .AttachFile strFile
    End With

    In the above statements strFile should contain the physical path of the file located in the server (assumed that you've uploaded the file).

    For example if the file is available under 'docs' folder :

    strFile = Server.MapPath(".")
    strFile = strFile & "\docs\" & filename


    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    Suggested Solutions

    Title # Comments Views Activity
    carriage return in xslt cell 13 55
    Auto Complete Using JQuery 5 60
    Google adds suggestions 3 43
    How to translate path in URL with PHP? 11 29
    Preface This is the third article about the EE Collaborative Login Project. A Better Website Login System ( introduces the Login System and shows how to implement a login page. The EE Collaborative Logi…
    What is Node.js? Node.js is a server side scripting language much like PHP or ASP but is used to implement the complete package of HTTP webserver and application framework. The difference is that Node.js’s execution engine is asynchronous and event…
    Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
    The viewer will learn how to count occurrences of each item in an array.

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now