0

我是 VbScript 的新手。我必须制作一个表格来上传文件并作为附件发送到指定的电子邮件。对于上传,我使用了这个脚本http://www.freeaspupload.net/freeaspupload/viewsource.asp 现在我的应用程序将文件保存到服务器。第二部分如下所示:

<% OPTION EXPLICIT

If Request.Cookies("QuoteRequest") = "Quote" THEN
    Dim fileName
    Dim strMsg
    Dim mail
    Dim strSubject
    Dim strFrom
    Dim strReply
    Dim strChoice
    Dim AddCheck
    Dim MyCheckDate
    Dim strMailBlindCopy

    Dim smtpserver
    Dim youremail
    Dim public_mailer
    Dim public_password

    smtpserver = ""
    youremail = ""
    public_mailer = ""   
    public_password = ""

    AddCheck = Request.Form("Str_xxrand234Myanswer")
    'Use this next line if you want a blind copy send for your records
    'strMailBlindCopy   = "info@ciupac.com"


    'IF AddCheck = "" or NULL THEN
    IF len(AddCheck)>2 OR len(AddCheck)<1 OR IsNumeric(AddCheck)=FALSE THEN 

        response.write "<a href=""javascript:history.back()""><h2>Sorry an error has occurred, please click here to return to the form</h2></a>" & AddCheck 


    Else

        Dim ObjSendMail
        Set ObjSendMail = CreateObject("CDO.Message") 

        'This section provides the configuration information for the remote SMTP server.

        ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 'Send the message using the network (SMTP over the network).
        ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = smtpserver
        ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25 
        ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = False 'Use SSL for the connection (True or False)
        ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60

        ' If your server requires outgoing authentication uncomment the lines bleow and use a valid email address and password.
        ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1 'basic (clear-text) authentication
        ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusername") = public_mailer
        ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword") = public_password

        ObjSendMail.Configuration.Fields.Update

        strFrom             = "Quote Request Form"
        strReply            = Request.Form("txtemail")

        strSubject = "Quote Request Form"


        strMsg = strMsg & "<b>Your Name:</b> " & Request.Form("txtname") & vbCrLF & vbCrLF & "<BR>" & "<BR>"    
        strMsg = strMsg & "<b>Your Company Name:</b> " & Request.Form("txtcompany") & vbCrLF & vbCrLF & "<BR>" & "<BR>" 
        strMsg = strMsg & "<b>Your Order Number:</b> " & Request.Form("txtyourorder") & vbCrLF & vbCrLF & "<BR>" & "<BR>"   
        strMsg = strMsg & "<b>Our Order Number:</b> " & Request.Form("txtourorder") & vbCrLF & vbCrLF & "<BR>"   & "<BR>"       
        strMsg = strMsg & "<b>Destination Postal Code:</b> " & Request.Form("txtpostal") & vbCrLF & vbCrLF & "<BR>"  & "<BR>"               
        strMsg = strMsg & "<b>Order Date:</b> " & Request.Form("txtdate") & vbCrLF & vbCrLF & "<BR>"         & "<BR>"                   
        strMsg = strMsg & "<b>Your E-mail Address:</b> " & Request.Form("txtemail") & vbCrLF & vbCrLF & "<BR>" & "<BR>" 
        strMsg = strMsg & "<b>Telephone #:</b> " & Request.Form("txtphone") & vbCrLF & vbCrLF & "<BR>" & "<BR>" 
        strMsg = strMsg & "<b>Comments:</b> " & Request.Form("txtcomments") & vbCrLF & vbCrLF & "<BR>" & "<BR>"
        strMsg = strMsg & "<b>Market Served:</b> " & Request.Form("option1") & ", " & Request.Form("option2") & ", " & Request.Form("option3") & ", " & Request.Form("option4") & ", " & Request.Form("option5") & ", " & Request.Form("option6") & ", " & Request.Form("option7") & ", " & Request.Form("option8") & ", " & Request.Form("option9") & ", " & Request.Form("option10") & ", " & Request.Form("option11") & ", " & Request.Form("option12") & ", " & Request.Form("option13") & ", " & Request.Form("option14") & vbCrLF & vbCrLF & "<BR>" & "<BR>"
        strMsg = strMsg & "<b>Topic of Interest:</b> " & Request.Form("option15") & ", " & Request.Form("option16") & ", " & Request.Form("option17") & ", " & Request.Form("option18") & ", " & Request.Form("option19") & ", " & Request.Form("option20") & ", " & Request.Form("option21") & ", " & Request.Form("option22") & ", " & Request.Form("option23") & ", " & Request.Form("option24") & ", " & Request.Form("option25") & ", " & Request.Form("option26") & ", " & Request.Form("option27") & ", " & Request.Form("option28") & ", " & Request.Form("option29") & ", " & Request.Form("option30") & ", " & Request.Form("option31") & ", " & Request.Form("option32") & vbCrLF & vbCrLF

        fileName = Request.Form("file")


        Dim strMailTo

        strMailTo =""
        ObjSendMail.To = strMailTo
        ObjSendMail.Subject = strSubject
        ObjSendMail.From = strReply
        ObjSendMail.HTMLBody = strMsg
        If Len(fileName)Then
            ObjSendMail.AddAttachment "C:\attachments\" & fileName 
        End If
        ObjSendMail.Send
        Set ObjSendMail = Nothing   




        Response.Redirect("thank-you.asp")
    END IF
ELSE
    Dim txtname
    Response.Write "ERROR <P>"
    fname=Request.Cookies("QuoteRequest")
    response.write("QuoteRequest=" & txtname)

END IF

%>

这两个脚本独立运行良好,但是当我尝试包含电子邮件发送部分以上传Cannot use Request.Form collection after calling BinaryRead错误时出现。我如何需要给电子邮件发件人打电话?

4

1 回答 1

1

由于表单的特殊 ENCTYPE="multipart/form-data" 属性,您不能使用 Reqest.Form 集合。请改用 Upload.Form,但仅在调用 Upload.Save(SaveVirtual、SaveToMemory)之后。

于 2013-08-02T07:48:55.180 回答