SitePoint Sponsor

User Tag List

Results 1 to 11 of 11
  1. #1
    SitePoint Wizard
    Join Date
    Apr 2004
    Location
    dublin
    Posts
    2,036
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How do I attach a File - word doc, etc?

    I want to attach a word document to a form.

    I have created a webpage form that user fills out and sends by clicking submit. They have the option to add a file.

    How do I do this??

    Here's some of my code (ASP)

    PHP Code:
      dim cv /*textfield to attach file  */
      
    cv=Request.Form("attachedfile")
      
       
    Set MyCDONTSMail CreateObject("CDONTS.NewMail")
            
    MyCDONTSMail.From email
            MyCDONTSMail
    .Subject "Job Application Form"
            
    MyCDONTSMail.To "mysite@fd.fd"
                'Attach File
                MyCDONTSMail.AttachFile(cv)
                
            MyBody = "Name: " & name & vbCrLf
                MyBody = MyBody & "Email: " & email & VbCrLf
                MyBody = MyBody & "Address: " & address1 & VbCrLf
            MyBody = MyBody & "Address2: " & address2 & VbCrLf
            MyBody = MyBody & "Country: " & country & VbCrLf
            MyBody = MyBody & "Phone: " & phone & VbCrLf
                MyBody = MyBody & "Education: " & education & VbCrLf
              MyBody = MyBody & "Current Position: " & current_position & VbCrLf
              MyBody = MyBody & "Position Applied For: " & position_applied & VbCrLf
                MyBody = MyBody & "Salary Expectations: " & salary & VbCrLf
                MyBody = MyBody & "Availability: " & availability & VbCrLf
            MyBody = MyBody & "Comments: " & VbCrLf & comments & VbCrLf
                MyBody = MyBody & "Attachment: " & cv & VbCrLf
                
                MyCDONTSMail.Body= MyBody
                MyCDONTSMail.Send
                set MyCDONTSMail = nothing
        
                                    %>
                            <p>Thank You <% Response.Write(name) %>.<br />Your application has been submitted.</p>
                            <% 

  2. #2
    SitePoint Wizard gRoberts's Avatar
    Join Date
    Oct 2004
    Location
    Birtley, UK
    Posts
    2,439
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I answered your question not long ago, you have to upload the file first using sa file up or aspupload or something like that. Then use the physical address to the file, ie:

    MyCDONTSMail.AttachFile("c:\inetpub\wwwroot\uploads\file.fil")

    Let me know if you need help on it.

    Gav

  3. #3
    Guru Bullschmidt's Avatar
    Join Date
    Apr 2002
    Location
    USA
    Posts
    524
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I did a form like that once and used the following to upload:

    ASP File Upload Using VBScript by John R. Lewis - 7/10/2000
    http://aspzone.com/articles/160.aspx

    And then immediately after sending the e-mail and attachment I had code delete the uploaded file on the server.
    Last edited by Bullschmidt; Jul 22, 2005 at 09:31.
    J. Paul Schmidt
    www.Bullschmidt.com - Freelance Web and Database Developer
    www.Bullschmidt.com/DevTip.asp - Classic ASP Design Tips

  4. #4
    SitePoint Wizard
    Join Date
    Apr 2004
    Location
    dublin
    Posts
    2,036
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Is my code for sending email correct??

    Could someone please show me an example of the code to send email with an attachment please.

    what I have been using isn't working.

    thanks.

  5. #5
    Guru Bullschmidt's Avatar
    Join Date
    Apr 2002
    Location
    USA
    Posts
    524
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The Samples section of http://www.asp101.com has some e-mail samples. The one using the e-mail attachment uses CDO which is a little newer than CDONTS which is deprecated and no longer ships with Windows.
    J. Paul Schmidt
    www.Bullschmidt.com - Freelance Web and Database Developer
    www.Bullschmidt.com/DevTip.asp - Classic ASP Design Tips

  6. #6
    SitePoint Wizard
    Join Date
    Apr 2004
    Location
    dublin
    Posts
    2,036
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    How do I upload to the server? i.e. If I want the user to be able to send an attachment??

    Thanks again!

  7. #7
    ALT.NET - because we need it silver trophybronze trophy dhtmlgod's Avatar
    Join Date
    Jul 2001
    Location
    Scotland
    Posts
    4,836
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Bullschmidt
    I did a form like that once and used the following to upload:

    ASP File Upload Using VBScript by John R. Lewis - 7/10/2000
    http://aspzone.com/posts/160.aspx

    And then immediately after sending the e-mail and attachment I had code delete the uploaded file on the server.
    Did you have a look at the posted link? I've used the supplied code before and it works perfectly.


  8. #8
    SitePoint Wizard
    Join Date
    Apr 2004
    Location
    dublin
    Posts
    2,036
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I would be very grateful if you could post sample code of how to email an attachment using a web form.

    Tried to follow above link but I'm messing it up somewhere. Also doesn't show me how to email the uploaded file.

    Thanks,

    Kevin.

  9. #9
    ALT.NET - because we need it silver trophybronze trophy dhtmlgod's Avatar
    Join Date
    Jul 2001
    Location
    Scotland
    Posts
    4,836
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Have a look at this: http://www.sitepoint.com/forums/show...ghlight=cdonts

    Can you post the WHOLE page your working with, including the HTML?

    Cheers


  10. #10
    SitePoint Wizard
    Join Date
    Apr 2004
    Location
    dublin
    Posts
    2,036
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Here is my html page. When the user hits submit they are taken to asp page which sends the form information and attachment by email.

    Thanks again!
    Code:
      
      
      <div id="wrapper">
      
      <div id="content">
      <p><span class="header">Submit Your CV</span>
      </p>
      
      <p>Please forward your resume using one of the following methods:</p>
      
      <p><img src="../images/option1.gif" alt="" />
      <span class="strong">Complete this Form:</span><br /></p>
      
      <form action="application.asp" name="form" method="post" enctype="multipart/form-data">
     <label for="name">Candidate Name: <span class="star">*</span></label> <input type="text" id="name" name="name" title="Enter Your Name" size="18" /><br />
     <label for="email">Email: <span class="star">*</span></label> <input type="text" id="email" name="email" title="Enter Your Email" size="18" /><br />
     <label for="current_position">Current Position Held Dates To - From: <span class="star">*</span></label> <input type="text" id="current_position" name="current_position" title="Enter Your Current Position" size="18" /><br />
     <label for="position_applied">Position Applied For: <span class="star">*</span></label> <input type="text" id="position_applied" name="position_applied" title="Enter the Position Applied For" size="18" /><br />
     <label for="education">Educational Background: <span class="star">*</span></label> <input type="text" id="education" name="education" title="Enter Your Education Background" size="18" /><br />
     <label for="salary">Salary Expectations: <span class="star">*</span></label> <input type="text" id="salary" name="salary" title="Enter Your Salary" size="18" /><br />
     <label for="availability">Available to Start in a New Position: <span class="star">*</span></label> <input type="text" id="availability" name="availability" title="Enter Date of Availablity" size="18" /><br />
     <label for="address1">Address 1: <span class="star">*</span></label> <input type="text" id="address1" name="address1" title="Enter first part of your address" size="18" /><br />
     <label for="address2">Address 2: <span class="star">*</span></label> <input type="text" id="address2" name="address2" title="Enter second part of address" size="18" /><br />
     <label for="country">Country: <span class="star">*</span></label> <input type="text" id="country" name="country" title="Enter your Country" size="18" /><br />
     <label for="phone">Phone: <span class="star">*</span></label> <input type="text" id="phone" name="phone" title="Enter your Phone Number" size="18" /><br />
      <label for="cv">Upload Your CV:</label> <input type="file" name="fileatt" /><br />
     <label for="comments">Additional Comments:</label> <textarea cols="36" rows="12" id="comments" name="comments" title="Enter any additional Comments"></textarea>
      <br /><br />
      <input type="hidden" name="submitted" value="true" />
      <input type="submit" name="submit" value="Submit" title="Send your request" />
      <br /><br />
      </form>
      
      </div>  <!-- end div content -->  
      
      </div>  <!-- end div wrapper -->
    Here's my asp code so far:
    PHP Code:
     <%
     
    Dim MyBody
     Dim Mail
         
     dim name
    emailcurrent_positionposition_appliededucationsalaryavailability
     dim address1
    address2countryphonecvcommentssubmitted
     
     
     submitted
    =Request.Form("submitted")
     
    name=Request.Form("name")
     
    email=Request.Form("email")
     
    current_position=Request.Form("current_position")
     
    position_applied=Request.Form("position_applied")
     
    education=Request.Form("education")
     
    salary=Request.Form("salary")
     
    availability=Request.Form("availability")
     
    comments=Request.Form("comments")
     
    address1=Request.Form("address1")
     
    address2=Request.Form("address2")
     
    country=Request.Form("country")
     
    phone=Request.Form("phone")
     
    cv=Request.Form("fileatt")
     
     
    'change to address of your own SMTP server
     strHost = "mail.elinkisp.com"
     
     ' 
    Because of the special ENCTYPE attribute we can no longer use Request.Form,
     
    ' we must use Upload.Form instead.
     
     Set Upload = Server.CreateObject("Persits.Upload")
     Upload.IgnoreNoPost = True
     
     ' 
    capture an upload and save uploaded files (if anyin temp directory
     Upload
    .Save "c:\upload"
     
     
    If submitted<>"true" Then
      
    %>
           <
    p>You did not press submit!</p>
      <%
      Else
               If (
    name "" or email ""Then
               
    %>
               <
    p>Please enter your name and email</p>
              <
    p><a href="#" onClick="history.go(-1)">Return</a></p><br />
               <%
                Else
                       If 
    country "" Then
                       
    %>
                        <
    p>Please enter your Country</p>
                       <
    p><a href="#" onClick="history.go(-1)">Return</a></p><br />
                       <%
                       Else
                               If (
    current_position "" or position_applied ""Then
                              
    %>
                              <
    p>Please enter your Current Position and Position Applied for</p>
                              <
    p><a href="#" onClick="history.go(-1)">Return</a></p><br />
                              <%
                              Else
                                       If 
    education "" Then
                                      
    %>
                                      <
    p>Please enter your education</p>
                                      <
    p><a href="#" onClick="history.go(-1)">Return</a></p><br />
                                      <%
                                      Else
                                               If 
    salary "" Then
                                              
    %>
                                              <
    p>Please enter your Salary</p>
                                               <
    p><a href="#" onClick="history.go(-1)">Return</a></p><br />
                                              <%
                                              Else
                                                       If 
    availability "" Then
                                                      
    %>
                                                      <
    p>Please enter your date of availability</p>
                                                        <
    p><a href="#" onClick="history.go(-1)">Return</a></p><br />
                                                       <% 
                                                      Else 
                                                                  If 
    phone "" Then
                                                                  
    %>
                                                                  <
    p>Please enter your Phone number</p>
                                                                    <
    p><a href="#" onClick="history.go(-1)">Return</a></p><br />
                                                                   <%
                                                                  Else
     
     
    Set Mail Server.CreateObject("CDONTS.NewMail")
     
     
    Mail.Host strHost
     Mail
    .AddAddress Upload.Form("To")
     
    Mail.From Upload.Form("email")
     
    Mail.To "info@pfpc.ie"
     
    Mail.Subject "Job Application Form"
     
              
     
    MyBody "Name: " name vbCrLf
     MyBody 
    MyBody "Email: " email VbCrLf
     MyBody 
    MyBody "Address: " address1 VbCrLf
     MyBody 
    MyBody "Address2: " address2 VbCrLf
     MyBody 
    MyBody "Country: " country VbCrLf
     MyBody 
    MyBody "Phone: " phone VbCrLf
     MyBody 
    MyBody "Education: " education VbCrLf
     MyBody 
    MyBody "Current Position: " current_position VbCrLf
     MyBody 
    MyBody "Position Applied For: " position_applied VbCrLf
     MyBody 
    MyBody "Salary Expectations: " salary VbCrLf
     MyBody 
    MyBody "Availability: " availability VbCrLf
     MyBody 
    MyBody "Comments: " VbCrLf comments VbCrLf
     MyBody 
    MyBody "Attachment: " cv VbCrLf
     
     Mail
    .Body MyBody
              
     
    ' Handle attached file via Upload.Files collection.
     ' 
    Check if a file was indeed uploaded
     
     
    If Not Upload.Files("fileatt"Is Nothing Then
              Mail
    .AddAttachment Upload.Files("fileatt").Path
     End 
    If
                 
     
     
    ' We are done. Send message
     Mail.Send
     %>
     <p>Thank You <% Response.Write(name) %>.<br />Your application has been submitted.</p>
     <%
        End If
            End If
                End If
                    End If
                        End If
                            End If
                                End If
                                    End If 

  11. #11
    SitePoint Wizard gRoberts's Avatar
    Join Date
    Oct 2004
    Location
    Birtley, UK
    Posts
    2,439
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Once you use persits upload.save all your request.form's turn into upload.forms

    I sent you some coding via pm, can you run it and reply with the contents.

    Kind regards

    Gav


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
  •