Results 1 to 10 of 10
  1. #1
    Join Date
    Apr 2005
    Posts
    194

    Simple ASP HELP Please!

    Hi,

    I have one simple form for submit resume option (upload and submit as attachgement with email).

    Every thing is working fine if I chose the upload file option. If not then not email is going out. I need to just make Attach Resume (Optional).

    Below is the code I have.
    ----------------------------------
    <%@ Language=VBScript %>
    <%Option Explicit%>
    <!-- #include file="upload.asp" -->
    <!--#include file="cdovbs.inc" -->

    <%
    ' Create the FileUploader
    Dim Uploader, File
    Set Uploader = New FileUploader

    ' This starts the upload process
    Uploader.Upload()


    ' Check if any files were uploaded
    If Uploader.Files.Count = 0 Then
    Response.Write "File(s) not uploaded."
    Else
    ' Loop through the uploaded files
    For Each File In Uploader.Files.Items
    ' Save the file to a directory of your server
    File.SaveToDisk Server.MapPath("/tst-em-form-upload/")

    Next
    Dim objMail,strWho,strTo,strFrom,strCC
    strWho = Uploader.form("name")
    strTo = "MyEmail@MyDomain.com"
    strCC=""
    strFrom = Request.ServerVariables("SERVER_NAME")
    Set objMail = CreateObject("CDONTS.NewMail")
    objMail.From = strFrom
    objMail.To = strTo
    objMail.Cc=strCC
    objMail.Subject = "Email Subject!"
    objMail.Body = "This is body text"
    objMail.importance = cdoHigh
    objMail.MailFormat = 0
    For Each File In Uploader.Files.Items
    objMail.AttachFile Server.MapPath("/tst-em-form-upload/"& File.FileName)
    Next
    objMail.Send
    Set objMail = nothing

    End If

    %>
    ----------------------------------



    As I am not programmer. Can any one help just modifying above code?


    Thank you in advance.
    Raza

  2. #2
    just don't check uploaded files count

    Code:
    ' Loop through the uploaded files
    For Each File In Uploader.Files.Items
    ' Save the file to a directory of your server
    File.SaveToDisk Server.MapPath("/tst-em-form-upload/")
    
    Next
    Dim objMail,strWho,strTo,strFrom,strCC
    strWho = Uploader.form("name")
    strTo = "MyEmail@MyDomain.com"
    strCC=""
    strFrom = Request.ServerVariables("SERVER_NAME")
    Set objMail = CreateObject("CDONTS.NewMail")
    objMail.From = strFrom
    objMail.To = strTo
    objMail.Cc=strCC
    objMail.Subject = "Email Subject!"
    objMail.Body = "This is body text"
    objMail.importance = cdoHigh
    objMail.MailFormat = 0
    For Each File In Uploader.Files.Items
    objMail.AttachFile Server.MapPath("/tst-em-form-upload/"& File.FileName)
    Next
    objMail.Send
    Set objMail = nothing
    HostNodeList Web Host Directory, DEV.INTOEX.COM - products for online business

    Experienced web-developer | PHP | Smarty | Zend | Databases | Graphic design - looking for long-time relationship

  3. #3
    Join Date
    Apr 2005
    Posts
    194
    Thanks xelav,

    Now its all working fine. But I have two field in the form I have: Name, Email.

    I want to add those into the email sent out.

    Any Idea hot wo do that?

  4. #4
    Join Date
    Oct 2003
    Location
    Morocco
    Posts
    550
    objMail.From = Uploader.form("Email")
    objMail.Body = "This is body text, name=" & Uploader.form("Name")
    RofyHost - Affordable Shared & Reseller Hosting Since 2003
    Proud Moroccan

  5. #5
    Join Date
    Apr 2005
    Posts
    194
    Thanks rofyhost,

    Its work great!

    But when I am doing with html it is not send out as HTML and format is set 0 whcih is html.

    I am using this.

    objMail.Body = "This is body text, <BR><B>Name:</B>=" & Uploader.form("Name")

    Any suggestion how to make it work fine?

  6. #6
    Join Date
    Oct 2003
    Location
    Morocco
    Posts
    550
    Hello AskAR,

    inorder for HTML to work fine you have to open/close correctly the html code before using any html codes in your objMail.Body, example:

    HTML = HTML & "<HTML>"
    HTML = HTML & "<HEAD>"
    HTML = HTML & "<TITLE>Send Mail with HTML</TITLE>"
    HTML = HTML & "</HEAD>"
    HTML = HTML & "<BODY bgcolor=""lightyellow"">"
    HTML = HTML & "<FONT color=""darkblue"" SIZE=""4"">"
    HTML = HTML & "This is body text, <BR><B>Name:</B>=" & Uploader.form("Name")
    HTML = HTML & "</FONT>"
    HTML = HTML & "</BODY>"
    HTML = HTML & "</HTML>

    objMail.Body = HTML

    Good luck
    RofyHost - Affordable Shared & Reseller Hosting Since 2003
    Proud Moroccan

  7. #7
    Join Date
    Apr 2005
    Posts
    194
    I did it by making one Dim HTML and past above code into that. and change objMail.Body = HTML

    And I received email with blank body.

  8. #8
    Join Date
    Oct 2003
    Location
    Morocco
    Posts
    550
    Hello,

    take out the dim HTML and try :

    objMail.Body = objMail.Body & "<HTML>"
    objMail.Body = objMail.Body & "<HEAD>"
    objMail.Body = objMail.Body & "<TITLE>Send Mail with HTML</TITLE>"
    objMail.Body = objMail.Body & "</HEAD>"
    objMail.Body = objMail.Body & "<BODY bgcolor=""lightyellow"">"
    objMail.Body = objMail.Body & "<FONT color=""darkblue"" SIZE=""4"">"
    objMail.Body = objMail.Body & "This is body text, <BR><B>Name:</B>=" & Uploader.form("Name")
    objMail.Body = objMail.Body & "</FONT>"
    objMail.Body = objMail.Body & "</BODY>"
    objMail.Body = objMail.Body & "</HTML>
    RofyHost - Affordable Shared & Reseller Hosting Since 2003
    Proud Moroccan

  9. #9
    Join Date
    Apr 2005
    Posts
    194
    Thanks rofyhost,

    I added there:
    objMail.BodyFormat=0
    objMail.MailFormat=0

    and make like this:
    objMail.Body = "This is body text, <BR><B>Name:</B>=" & Uploader.form("Name")

    Now its working fine.

    Thanks you very much.

  10. #10
    Join Date
    Oct 2003
    Location
    Morocco
    Posts
    550
    Happy for you
    RofyHost - Affordable Shared & Reseller Hosting Since 2003
    Proud Moroccan

Posting Permissions

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