45 users online (0 members and 45 guests)  


Page 1 of 2 1 2 Last
  Results 1 to 15 of 18

Related

  1. Hello I am newbie here    Forum: Introduce Yourself
    Replies: 0
  2. Newbie    Forum: Search Engine Optimization - SEO - Forum
    Replies: 0
  3. newbie    Forum: General Discussion
    Replies: 0
  4. i'm a newbie    Forum: Web Hosting Forum
    Replies: 2
  1. #1
    Deedee's Avatar
    New User

    Status
    Offline
    Join Date
    May 2003
    Posts
    17

    Please help a newbie

    Hi, I am new at this, and I guess too much of a pain, but I am desperately in need of some help. I really need to get this form working for the company that I am presently working for as a temp.

    • Here's what I'm trying to accomplish:
    -----------------------------------------------------
    The form is an application and the applicant is supposed to be
    attaching his/her resume to send with the form. The whole thing gets sent as an e-mail. (Windows-based server)

    • Here' the problem....
    ---------------------------------
    I am using ASP Mail to return a feedback form and it works fine.
    When I tried to use the same form, only adding the line
    [mailObj.AddAttachment "C:\boot.ini"] without the brackets, to
    the formmail script and adding the <input type="file"> tag to the form, it doesn't work. After filling out the form, attaching a file, and hitting the submit button, I get a "Form could not be processed due to the following errors: •Missing e-mail recipient"


    • Here is the form tag from the 'test' application form:
    ------------------------------------------------------------------
    '<form name="Resume" action="/forms/formmail.asp" method="post"
    enctype="multipart/form-data">
    <input name="_recipients" type="hidden" value="to_diane@c... />


    • This is the custumizable part of the formmail script:
    ----------------------------------------------------------------------

    '- Customization of these values is required, see documentation. ---------------

    referers = Array("www.cox.com", "www.cox.net")
    mailComp = "ASPMail"
    smtpServer = "smtp.central.cox.net"
    fromAddr = "to_diane@c..."
    '- End required customization section.
    -------------------------------------


    • Here is where I added the AddAttachment in the script (line 10):---------------------------------------------------------


    'Send email (ASPMail version).
    if mailComp = "ASPMail" then
    set mailObj = Server.CreateObject("SMTPsvg.Mailer")
    mailObj.FromAddress = fromAddr
    mailObj.RemoteHost = smtpServer
    mailObj.ReplyTo = replyTo
    for each addr in Split(recipients, ",")
    mailObj.AddRecipient "", Trim(addr)
    next
    mailObj.AddAttachment "C:\boot.ini"
    mailObj.Subject = subject
    mailObj.ContentType = "text/html"
    mailObj.BodyText = body
    if not mailObj.SendMail then
    SendMail = "Email send failed: " & mailObj.Response & "."
    end if

    -------------------------------------------------------------------

    Can anyone tell from this info what I need to fix?

    Also, is "C:\boot.ini" supposed to be left in there as a generic
    place to start, or do I change it to something else? I got this
    script from the web.

    OR......is there a better, easier way to accomplish what I'm
    trying to accompish with this?

    would surely appreciate anyone with the patience to help me with this.
    TIA,
    D.

  2. #2
    Doorknob's Avatar
    Super Newbie

    Status
    Offline
    Join Date
    Jun 2002
    Location
    Malaysia
    Posts
    316
    'Send email (ASPMail version).
    if mailComp = "ASPMail" then
    set mailObj = Server.CreateObject("SMTPsvg.Mailer")
    mailObj.FromAddress = fromAddr
    mailObj.RemoteHost = smtpServer
    mailObj.ReplyTo = replyTo

    for each addr in Split(recipients, ",") <-- i don't see where the recipients is coming from, it could be null, in which case no email addresses are getting passed to the component. u COULD try debugging, u know

    mailObj.AddRecipient "", Trim(addr) <-- if recipients is null then addr would be null. if u are unsure, debug line-by-line and check the values that get sent. try sending 1 email add, then incrementing that by 1. if it works with 3 email addresses it should work fine with 1000.

    next
    mailObj.AddAttachment "C:\boot.ini"
    mailObj.Subject = subject
    mailObj.ContentType = "text/html"
    mailObj.BodyText = body
    if not mailObj.SendMail then
    SendMail = "Email send failed: " & mailObj.Response & "."
    end if

    hope that helps

  3. #3
    Doorknob's Avatar
    Super Newbie

    Status
    Offline
    Join Date
    Jun 2002
    Location
    Malaysia
    Posts
    316
    <input name="_recipients" type="hidden" value="to_diane@c... />

    ~~ make sure that recipients = request.form("_recipients") is around, u might have got the form object name wrong.

  4. #4
    Deedee's Avatar
    New User

    Status
    Offline
    Join Date
    May 2003
    Posts
    17
    I did try debugging. It doesn't tell a beginner anything useful. :-)
    I am printing your comments and checking it out. I'll also go through line by line as you suggest.

    What I don't understand is, why is there all this problem? The script is exactly as I got it from, I think, www.brainjar.com I've been cruisin' around the web getting scripts so much, I'm not 100% positive on that.

    Thanks a million for taking the time to try to help me.

    Have a wonderful sunny day!
    D.

  5. #5
    Doorknob's Avatar
    Super Newbie

    Status
    Offline
    Join Date
    Jun 2002
    Location
    Malaysia
    Posts
    316
    that's the problem there, as u pointed out, the script is exactly as u got it
    most scripts require customization, also, not all websites give good scripts or scripts with full explanations on customization.

    if u are unsure of why it doesn't work, just debug line by line. also, go to your IE's TOOLS, INTERNET OPTIONS, ADVANCED, and ensure that "Show friendly HTTP errors" is unchecked.

    that way you can see the actual error messages that the server sends instead of a user-friendly one-size-fits-all windows error page that doesn't tell u nuts

    in fact, if u really can't figure out the problem, u can send the whole script to me (nazrix@budweiser.com) and i can try and help u with it. hope that helps

  6. #6
    Deedee's Avatar
    New User

    Status
    Offline
    Join Date
    May 2003
    Posts
    17
    Thanks, I may take you up on your offer. For right now I'm going to see if I can muddle through a bit (with your help). When I tried it this morning it says there is a problem with Line 9 of the code. That's this line: "for each addr in Split(recipients, ",")"

    I didn't know what to put there, so I put an underscore in front of "recipients" to match the line in the form and an e-mail address between the "". Can I just take out this "Split" thing? I only need the form to go to one person.

    Thx,
    D.

  7. #7
    Doorknob's Avatar
    Super Newbie

    Status
    Offline
    Join Date
    Jun 2002
    Location
    Malaysia
    Posts
    316
    ok, i'll try to explain. u mentioned that when u add an attachment and send, u'r missing recipients.

    for each addr in Split(recipients, ",")

    recipients would be an array, holding several email addresses, split by ","; for example, when u use a normal web based email like hotmail, there is an input box for u to enter email addresses of people u want to send it to ie "test@hotmail.com,blargh@yahoo.com"
    the line of code above would loop through the array, taking out each email address, and use the line of code "mailObj.AddRecipient "", Trim(addr)" and the asp mail object to add the addresses. so i assume that your recipient array is empty. i think that if u hardcode an email address in, add the line of code below

    recipients = "your_email_address"

    and you will find that it works fine u shouldn't take out the split thing, unless u want to only ever send emails to one person. it's difficult to help when u don't provide all the source code though. hope that helps

  8. #8
    Deedee's Avatar
    New User

    Status
    Offline
    Join Date
    May 2003
    Posts
    17
    Good morning,
    You explain this very well. Thank you. What I did was change "addr in Split(recipients, ",")" to "addr in Split(_recipients, "email removed")".

    I'm assuming then that the e-mail address is probably okay, so I wil try putting the recipients back the way it was.

    Here is the script. Sorry, I thought I had already posted it. This script is just as I originally copied it, EXCEPT for the customization section and the 9th line from the bottom where I added the AddAttachment line. --Diane :-)

    //////////////ASP FORMMAIL SCRIPT////////////////

    <%@ LANGUAGE="VBScript" %>
    <% '***************************************************************************
    '* ASP FormMail *
    '* *
    '* Do not remove this notice. *
    '* *
    '* Copyright 1999-2002 by Mike Hall. *
    '* Please see http://www.brainjar.com for documentation and terms of use. *
    '***************************************************************************
    '- Customization of these values is required, see documentation. -----------
    Option Explicit
    Dim recipients
    recipients = Request.Form("_recipients")
    referers = Array("www.cox.com", "www.cox.net")
    mailComp = "ASPMail"
    smtpServer = "smtp.central.cox.net"
    fromAddr = "email removed"
    '- End required customization section. -------------------------------------
    Response.Buffer = true
    errorMsgs = Array()
    'Check for form data.
    if Request.ServerVariables("Content_Length") = 0 then
    call AddErrorMsg("No form data submitted.")
    end if
    'Check if referer is allowed.
    validReferer = false
    referer = GetHost(Request.ServerVariables("HTTP_REFERER"))
    for each host in referers
    if host = referer then
    validReferer = true
    end if
    next
    if not validReferer then
    if referer = "" then
    call AddErrorMsg("No referer.")
    else
    call AddErrorMsg("Invalid referer: '" & referer & "'.")
    end if
    end if
    'Check for the recipients field.
    if Request.Form("_recipients") = "" then
    call AddErrorMsg("Missing email recipient.")
    end if
    'Check all recipient email addresses.
    recipients = Split(Request.Form("_recipients"), ",")
    for each name in recipients
    name = Trim(name)
    if not IsValidEmail(name) then
    call AddErrorMsg("Invalid email address in recipient list: " & name & ".")
    end if
    next
    recipients = Join(recipients, ",")
    'Get replyTo email address from specified field, if given, and check it.
    name = Trim(Request.Form("_replyToField"))
    if name <> "" then
    replyTo = Request.Form(name)
    else
    replyTo = Request.Form("_replyTo")
    end if
    if replyTo <> "" then
    if not IsValidEmail(replyTo) then
    call AddErrorMsg("Invalid email address in reply-to field: " & replyTo & ".")
    end if
    end if
    'Get subject text.
    subject = Request.Form("_subject")
    'If required fields are specified, check for them.
    if Request.Form("_requiredFields") <> "" then
    required = Split(Request.Form("_requiredFields"), ",")
    for each name in required
    name = Trim(name)
    if Left(name, 1) <> "_" and Request.Form(name) = "" then
    call AddErrorMsg("Missing value for " & name)
    end if
    next
    end if
    'If a field order was given, use it. Otherwise use the order the fields were
    'received in.
    str = ""
    if Request.Form("_fieldOrder") <> "" then
    fieldOrder = Split(Request.Form("_fieldOrder"), ",")
    for each name in fieldOrder
    if str <> "" then
    str = str & ","
    end if
    str = str & Trim(name)
    next
    fieldOrder = Split(str, ",")
    else
    fieldOrder = FormFieldList()
    end if
    'If there were no errors, build the email note and send it.
    if UBound(errorMsgs) < 0 then
    'Build table of form fields and values.
    body = "<table border=""0"" cellpadding=""2"" cellspacing=""0"">" & vbCrLf
    for each name in fieldOrder
    body = body _
    & "<tr valign=""top"">" _
    & "<td><b>" & name & ":</b></td>" _
    & "<td>" & Request.Form(name) & "</td>" _
    & "</tr>" & vbCrLf
    next
    body = body & "</table>" & vbCrLf
    'Add a table with any environmental variables.
    if Request.Form("_envars") <> "" then
    body = body _
    & "<p>&nbsp;</p>" & vbCrLf _
    & "<table border=""0"" cellpadding=""2"" cellspacing=""0"">" & vbCrLf
    envars = Split(Request.Form("_envars"), ",")
    for each name in envars
    name = Trim(name)
    body = body _
    & "<tr valign=""top"">" _
    & "<td><b>" & name & ":</b></td>" _
    & "<td>" & Request.ServerVariables(name) & "</td>" _
    & "</tr>" & vbCrLf
    next
    body = body & "</table>" & vbCrLf
    end if
    'Send it.
    str = SendMail()
    if str <> "" then
    AddErrorMsg(str)
    end if
    'Redirect if a URL was given.
    if Request.Form("_redirect") <> "" then
    Response.Redirect(Request.Form("_redirect"))
    end if
    end if %>

    <html>
    <head>
    <title>Form Mail</title>
    <style style="text/css">
    body {
    background-color: #ffffff;
    color: #000000;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 10pt;
    }
    table {
    border: solid 1px #000000;
    border-collapse: collapse;
    }
    td, th {
    border: solid 1px #000000;
    border-collapse: collapse;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 10pt;
    padding: 2px;
    padding-left: 8px;
    padding-right: 8px;
    }
    th {
    background-color: #c0c0c0;
    }
    .error {
    color: #c00000;
    }
    </style>
    </head>
    <body>
    <% if UBound(errorMsgs) >= 0 then %>
    <p class="error">Form could not be processed due to the following errors:</p>
    <ul>
    <% for each msg in errorMsgs %>
    <li class="error"><% = msg %>
    <% next %>
    </ul>
    </table>
    <% else %>
    <table cellpadding="0" cellspacing="0">
    <tr>
    <th colspan="2" valign="bottom">
    Thank you, the following information has been sent:
    </th>
    </tr>
    <% for each name in fieldOrder %>
    <tr valign="top">
    <td><b><% = name %></b></td>
    <td><% = Request.Form(name) %></td>
    </tr>
    <% next %>
    </table>
    <% end if %>
    </body>
    </html>
    <% '---------------------------------------------------------------------------
    ' Subroutines and functions.
    '---------------------------------------------------------------------------
    sub AddErrorMsg(msg)
    dim n
    'Add an error message to the list.
    n = UBound(errorMsgs)
    Redim Preserve errorMsgs(n + 1)
    errorMsgs(n + 1) = msg
    end sub
    function GetHost(url)
    dim i, s
    GetHost = ""
    'Strip down to host or IP address and port number, if any.
    if Left(url, 7) = "http://" then
    s = Mid(url, 8)
    elseif Left(url, 8) = "https://" then
    s = Mid(url, 9)
    end if
    i = InStr(s, "/")
    if i > 1 then
    s = Mid(s, 1, i - 1)
    end if
    getHost = s
    end function
    function IsValidEmail(email)
    dim names, name, i, c
    'Check for valid syntax in an email address.
    IsValidEmail = true
    names = Split(email, "@")
    if UBound(names) <> 1 then
    IsValidEmail = false
    exit function
    end if
    for each name in names
    if Len(name) <= 0 then
    IsValidEmail = false
    exit function
    end if
    for i = 1 to Len(name)
    c = Lcase(Mid(name, i, 1))
    if InStr("abcdefghijklmnopqrstuvwxyz_-.", c) <= 0 and not IsNumeric(c) then
    IsValidEmail = false
    exit function
    end if
    next
    if Left(name, 1) = "." or Right(name, 1) = "." then
    IsValidEmail = false
    exit function
    end if
    next
    if InStr(names(1), ".") <= 0 then
    IsValidEmail = false
    exit function
    end if
    i = Len(names(1)) - InStrRev(names(1), ".")
    if i <> 2 and i <> 3 then
    IsValidEmail = false
    exit function
    end if
    if InStr(email, "..") > 0 then
    IsValidEmail = false
    end if
    end function
    function FormFieldList()
    dim str, i, name
    'Build an array of form field names ordered as they were received.
    str = ""
    for i = 1 to Request.Form.Count
    for each name in Request.Form
    if Left(name, 1) <> "_" and Request.Form(name) is Request.Form(i) then
    if str <> "" then
    str = str & ","
    end if
    str = str & name
    exit for
    end if
    next
    next
    FormFieldList = Split(str, ",")
    end function
    function SendMail()
    dim mailObj
    dim addrList
    'Send email based on mail component. Uses global variables for parameters
    'because there are so many.
    SendMail = ""
    'Send email (CDONTS version), doesn't support reply-to address and has
    'no error checking.
    if mailComp = "CDONTS" then
    set mailObj = Server.CreateObject("CDONTS.NewMail")
    mailObj.BodyFormat = 0
    mailObj.MailFormat = 0
    mailObj.From = fromAddr
    mailObj.To = recipients
    mailObj.Subject = subject
    mailObj.Body = body
    mailObj.Send
    end if
    'Send email (JMail version).
    if mailComp = "JMail" then
    set mailObj = Server.CreateObject("JMail.SMTPMail")
    mailObj.Silent = true
    mailObj.ServerAddress = smtpServer
    mailObj.Sender = fromAddr
    mailObj.ReplyTo = replyTo
    mailObj.Subject = subject
    addrList = Split(recipients, ",")
    for each addr in addrList
    mailObj.AddRecipient Trim(addr)
    next
    mailObj.ContentType = "text/html"
    mailObj.Body = body
    if not mailObj.Execute then
    SendMail = "Email send failed: " & mailObj.ErrorMessage & "."
    end if
    end if
    'Send email (ASPMail version).
    if mailComp = "ASPMail" then
    set mailObj = Server.CreateObject("SMTPsvg.Mailer")
    mailObj.FromAddress = fromAddr
    mailObj.RemoteHost = smtpServer
    mailObj.ReplyTo = replyTo
    for each addr in Split(recipients, ",")
    mailObj.AddRecipient "", Trim(addr)
    next
    'mailObj.AddAttachment "C:\boot.ini"'
    mailObj.Subject = subject
    mailObj.ContentType = "text/html"
    mailObj.BodyText = body
    if not mailObj.SendMail then
    SendMail = "Email send failed: " & mailObj.Response & "."
    end if
    end if
    end function %>

  9. #9
    Doorknob's Avatar
    Super Newbie

    Status
    Offline
    Join Date
    Jun 2002
    Location
    Malaysia
    Posts
    316
    looks like u aren't receiving your recipients. make sure your form has <input type=text name='_recipients'>

    because
    recipients = Request.Form("_recipients")
    passes the value of the input field from the form and

    'Check for the recipients field.
    if Request.Form("_recipients") = "" then
    call AddErrorMsg("Missing email recipient.")
    end if

    finds that the form did not send any values over, maybe because u got the textfield wrong

  10. #10
    Deedee's Avatar
    New User

    Status
    Offline
    Join Date
    May 2003
    Posts
    17
    Hello again,

    I think I've figured out a large part of the problem. The formmail.asp works fine for the feedback form and it also works fine for the resume form as long as I leave out the "enctype=multi/form-data" and the <input="file"> tag in the form.

    I went back to the site where I got the script and read some more and found out that ASP doesn't support file uploads. (At least that's what they said.)

    So....I guess I need to use CDONTS. Trouble is, when I tried that script, I got the e-mail but not the form results with it. I haven't tried the one with the upload attachment, but I have a feeling the results would be the same, plus I don't know how to configure it.

    Do you know how I can use CDONTS? Where I can get a script that will do what I need it to do (which is send the application form results via e-mail along with a resume that the applicant attaches to the e-mail)? Or do you know a link for a CDONTS tutorial where I can learn this fairly quickly? I've been working on this problem for weeks now and they're going to give up on me getting it working soon.

    Thanks so much for your help.
    D.

  11. #11
    Doorknob's Avatar
    Super Newbie

    Status
    Offline
    Join Date
    Jun 2002
    Location
    Malaysia
    Posts
    316
    i'm sorry, i have no experience with CDONTS. check out DEJANEWS or get a reference book

  12. #12
    Deedee's Avatar
    New User

    Status
    Offline
    Join Date
    May 2003
    Posts
    17
    Well, do you know of a better script to use? Do you think ASP will do the job. The Web site could be wrong.

    D.

  13. #13
    Doorknob's Avatar
    Super Newbie

    Status
    Offline
    Join Date
    Jun 2002
    Location
    Malaysia
    Posts
    316
    as i said, i don't have any experience with CDONTS. u could check out www.dejanews.com u can find developer forums there.

  14. #14
    Deedee's Avatar
    New User

    Status
    Offline
    Join Date
    May 2003
    Posts
    17
    Hi,
    Sorry to bother you again. Yea, I know you have no experience with CDONTS, I just thought you might know a way to do it with ASP.

    I tried the dejanews link you gave, but it doesn't work.

    Thanks,
    Deedee

  15. #15
    QuietDean's Avatar
    Administrator

    Status
    Offline
    Join Date
    Oct 2000
    Location
    Bournemouth, UK
    Posts
    2,662
    Theres an accidental comma at the end, just remove it manually.
    If one of our members helps you, please click the icon to add to their reputation!
    No support via email or private message - use the forums!
    Before you ask, have you Searched?



Page 1 of 2 1 2 Last

Tags for this Thread