SitePoint Sponsor

User Tag List

Results 1 to 5 of 5

Thread: add attachment

  1. #1
    SitePoint Enthusiast
    Join Date
    Nov 2009
    Posts
    73
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    add attachment

    Hi

    I have a simple working contact form.

    Code:
    <form method="post" action="process.asp" name="myform">
                                    <label for="Name">Name:</label>
                                    <input type="text" name="Name" id="Name" />
                                    
                                    <label for="Email">Email:</label>
                                    <input type="text" name="Email" id="Email" />
                                    
                                    <label for="Email">Telephone:</label>
                                    <input type="text" name="Telephone" id="Telephone" />
                                    
                                                                    
                                    <label for="Message">Message:</label><br />
                                  <textarea name="Message" rows="40" cols="20" id="Message"></textarea>
                                    <div>
                                    <input type="image" src="assets/img/sendBtn.png" name="submit" value="Submit" class="submit-button" />
                                    </div>
                              </form>
    The asp:

    Code:
    Set ObjSendMail = CreateObject("CDO.Message")
      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") =""
      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
      ObjSendMail.Configuration.Fields.Update
      ObjSendMail.To      = "myemail@email.com"
      ObjSendMail.Subject = "Query"
      ObjSendMail.From    = Session("email")
      ObjSendMail.TextBody= messageBody
      
      ObjSendMail.Send
      Set ObjSendMail = Nothing
      
      Response.Write("Email has been sent")
    I want the user to have the facility of uploading a word document.

    I add this line here:
    Code:
    ObjSendMail.From    = Session("email")
      ObjSendMail.TextBody= messageBody
      ObjSendMail.AddAttachment Request.Form("rob")
    i add this to the html form:
    Code:
    <label for="Email">CV:</label>
                                    <input type="hidden" name="rob" value="100" />
    								<input name="file" type="file" />
    The form has stopped submitting and produces the error:
    Code:
    CDO.Message.1 error '800c000d' 
    
    Unknown Error 
    
    /process.asp, line 29
    line 29 is this:
    Code:
    ObjSendMail.AddAttachment Request.Form("rob")
    Can anyone spot what i am missing here please?

    Thanks

  2. #2
    SitePoint Wizard siteguru's Avatar
    Join Date
    Oct 2002
    Location
    Scotland
    Posts
    3,631
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    You can't upload files in that way - you need something to process the file.

    Check if your hosting server includes relevant components (Such as Persits.Upload). Otherwise take a look at PureASPUpload.
    Ian Anderson
    www.siteguru.co.uk

  3. #3
    SitePoint Enthusiast
    Join Date
    Nov 2009
    Posts
    73
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by siteguru View Post
    You can't upload files in that way - you need something to process the file.

    Check if your hosting server includes relevant components (Such as Persits.Upload). Otherwise take a look at PureASPUpload.
    I have managed to get this working now but i have a slight problem...

    I am using the Persits.Upload component as i found out that it is provided by my hosting company.

    Great i can now upload and send attachments via email, but because i am using

    Code:
    ENCTYPE="multipart/form-data"
    the request.form("name") and request.form("email") are blanked out so i dont know who is emailing me the attachments.

    When i dont use the entype in the form the request.form fields are populated.

    I know its something simple i am missing here but i cant seem to work out what it is can anyone advise please?

  4. #4
    SitePoint Addict itHighway's Avatar
    Join Date
    Jan 2008
    Location
    GUJ
    Posts
    270
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    As you are using multipart/form-data so Request.Form will not work. You may need to use the ASPUpload object name to get the variable.

    For example:
    Set Upload = Server.CreateObject("Persits.Upload")
    ....
    varDocument = Upload.Form("VariableName")
    You can find sample script of email attachment with Persits Upload at aspUpload.com website.
    Last edited by itHighway; Mar 31, 2011 at 10:08. Reason: persits website name

  5. #5
    SitePoint Enthusiast
    Join Date
    Nov 2009
    Posts
    73
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by itHighway View Post
    As you are using multipart/form-data so Request.Form will not work. You may need to use the ASPUpload object name to get the variable.

    For example:


    You can find sample script of email attachment with Persits Upload at aspUpload.com website.
    Thanks for your help! I used upload.form("variable") and it worked


Bookmarks

Posting Permissions

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