www.webdeveloper.com
Results 1 to 4 of 4

Thread: ASP code attachment problem

  1. #1
    Join Date
    Aug 2008
    Posts
    1

    Post ASP code attachment problem

    I have made below two file for sending email with attachment.
    but it does not work properly.
    I want to upload file form user pc.
    not form my server path. and save it to my mail.

    two files are below
    1. form.html



    <html>
    <head>
    <title>form to email script</title>
    </head>
    <body>

    <div align="center">
    <form method="POST" action="form_ac.asp" name="form1">
    <table width="75%" border="0" cellspacing="0" cellpadding="0">
    <tr>
    <td>name:</td>
    <td colspan="2">
    <input type="text" name="name"></td>
    </tr>
    <tr>
    <td>email:</td>
    <td colspan="2">
    <input type="text" name="email"></td>
    </tr>
    <tr>
    <td>message:</td>
    <td colspan="2">
    <textarea name="message" cols="40" rows="5"></textarea></td>
    </tr>
    <tr>
    <td>&nbsp;</td>
    <td colspan="2"><label>
    <input type="file" name="attach">
    </label></td>
    </tr>
    <tr>
    <td>&nbsp;</td>
    <td colspan="2">
    <input type="submit" name="Submit" value="Submit">
    <input type="reset" name="Reset" value="Reset"></td>
    </tr>
    </table>
    </form>
    </div>
    </body>
    </html>
    ===========================================

    2. form_ac.asp


    <%@ Language="VBscript" %>
    <% Option Explicit %>

    <html>
    <head>
    <title>Message Sent</title>
    </head>

    <body>
    <%
    'declare the variables that will receive the values
    'receive the values sent from the form and assign them to variables
    'note that request.form("name") will receive the value entered into the textfield
    'called name, and so with email and message
    Dim name, email, message, NewMailObj
    name=request.form("name")
    email=request.form("email")
    message=request.form("message")

    'create the mail object and send the details
    Set NewMailObj=Server.CreateObject("CDONTS.NewMail")
    NewMailObj.From = "yuo@mail.com"
    NewMailObj.To = "you@mail.com"
    NewMailObj.Subject = "New message sent.."
    NewMailObj.Body = "the name you entered was " & name & _
    "<br>the email was " & email & _
    "<br>the message was " & message

    'you need to add the following lines FOR the mail to be sent in HTML format
    NewMailObj.BodyFormat = 0
    NewMailObj.MailFormat = 0
    newMailObj.AddAttachment Request.Form("attach")
    NewMailObj.Send
    'Close the email object and free up resources
    Set NewMailObj = nothing
    Response.write "The email was sent."
    %>

    </body>
    </html>
    =========================================

  2. #2
    Join Date
    Jan 2006
    Posts
    56
    What happens when you submit the form?


    Cheers
    Shane
    Website Design Melbourne

  3. #3
    Join Date
    Jul 2008
    Posts
    5

    same

    I am having the same problem. It gives me this error whenever I try opening it in my web browser:

    Microsoft VBScript runtime error '800a01b6'

    Object doesn't support this property or method: 'BodyFormat'

  4. #4
    Join Date
    Jan 2003
    Location
    USA
    Posts
    688
    It's a little convoluted but what has worked for me is to use some kind of file uploader (perhaps an ASP class of code) to upload file to server, then attach the file from the server to your e-mail in code of course, then delete the file from the server.

    And regarding the first post nowadays CDO is used more than CDONTS for sending e-mail.
    J. Paul Schmidt
    www.Bullschmidt.com - Freelance Web and Database Developer
    www.Bullschmidt.com/DevTip.asp - Classic ASP Design Tips

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles