• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 393
  • Last Modified:

Attaching a file to an email asp page

Hi All!

So... I've got a questionnaire form working properly at http://www.hhs1.com/questionnaire.html

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("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "mail.connectwise.com"
End With
With MyMail
Set .Configuration = iConf
.To = "jimi@HHS1.com"
.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 http://www.hhs1.com/questionnaire.html , 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.



1 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

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.

Join & Write a Comment

Featured Post

Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now