How to convert web form to email with uploaded file as attachment in classic ASP ?

Discussion in 'Programming' started by ccclock, Nov 5, 2014.

  1. #1
    I am not familiar with ASP but I am helping my friend update his web page in classic ASP with a HTML form that sends an email on submit There is a field of file in the form that user may upload any file. The HTML code would look like below.

    <form method="post" action="contact.asp" enctype="multipart/form-data" >
    <input type="text" name="name" id="name">
    <input type="file" name="myFile" id="myFile">
    <input type="submit" value="Submit">
    </form>

    I’ve google some CDO codes below to send the email with attachment.

    <%
    Set myMail=CreateObject("CDO.Message")
    myMail.Subject="Sending email with CDO"
    myMail.From=""
    myMail.To=""
    myMail.TextBody="Message sent from " & Request("name")
    myMail.AddAttachment "c:\mydocuments\test.txt"
    myMail.Send
    set myMail=nothing
    %>

    I have no idea what the code of file uploading process should be in order to place the path and file name in the line of myMail.AddAttachment. Note that the file may have file name in Chinese or Japanese.

    How can the script of contact.asp be in order to convert the form to email with file attachment with CDO ?

    Thank you.
     
    ccclock, Nov 5, 2014 IP