SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Enthusiast
    Join Date
    Nov 2006
    Location
    United States
    Posts
    31
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Mail form sends multiple copies?

    I've been trying to figure this out for about an hour now but a combination of my own narrow scope and limited experience, coupled with a general lack of information on this sort of thing has this ASP newbie scratching his head. I was told that the issue with receiving multiple instances of the document is relevant to this chunk of code:

    Code:
    If Request.Form.Count > 0 Then
        For I = 1 to Request.Form.Count
            Body = Body & Request.Form.Key(I) & " " _
                   & Request.Form.Item(I) & VbCrLf
        Next
    I've tried different things but I've always come up short. I have a feeling that it's probably something simple that I somehow managed to overlook. Help would be appreciated.

  2. #2
    SitePoint Wizard
    Join Date
    Nov 2004
    Location
    Nelson BC
    Posts
    2,310
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That code just makes a variable called Body that contains the items send via the form, specifically the item name and value.

    If the guy is receiving multiple copies of the same information then it's likely that the form is being submitted various times, or you are sending multiple emails once you have the Body variable created.

  3. #3
    SitePoint Enthusiast
    Join Date
    Nov 2006
    Location
    United States
    Posts
    31
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ah, so I've been mislead about "the first part." The way he put it, he said he's surprised that he's only getting two because something in the code makes it open to endless loops (or something to that effect).

    The complete code (bare with me):
    Code:
    <%
    If Request.Form.Count > 0 Then
        For I = 1 to Request.Form.Count
            Body = Body & Request.Form.Key(I) & " " _
                   & Request.Form.Item(I) & vbCRLF
        Next
     
    MAILSERVER = "websmtp.globalweb.net"
    PRIMARY = "---address nixed---"     'PRIMARY RECIPIENT
    SECONDARY = ""   'SECONDARY RECIPIENT
    CUSTOMER = Request.Form("email")
    SUBJECT = "Membership Form"
     
    ' ***** JMAIL SETTINGS FOLLOW HERE ****
    Set Mailer = Server.CreateObject("JMail.SMTPMail")
    Mailer.ServerAddress = MAILSERVER
    Mailer.Sender = CUSTOMER
    Mailer.AddRecipient PRIMARY
     
    '***BEGIN SPECIAL COPY/BLIND COPY LINES*******
    'REM THE NEXT LINE IF SECONDARY E-MAIL IS NOT TO BE USED (place a single quote at beginning of line)
    'Mailer.AddRecipient SECONDARY
    'OPTION TO BCC THE SECONDARY - REM ABOVE AND UNREM BELOW TO USE
    'Mailer.AddRecipientBCC SECONDARY
    '***END COPY LINES***
     
    Mailer.Subject = SUBJECT
    Mailer.Body = body
    Mailer.ISOEncodeHeaders = false
    Mailer.AddHeader "Originating-IP", Request.ServerVariables("REMOTE_ADDR")
    Mailer.Execute
    'Mailer.ContentType = "text/html" 'UNCOMMENT THIS LINE IF USING HTML TAGS IN YOUR MESSAGE BODY
     
    'if not Mailer.SendMail then
    if not Mailer.Execute then
      Response.Write "Could not process at this time.  Please try again later."
    else
      response.write "<font size=4 color=ff0000>Information sent successfully!<br> Please print this screen for your records. Thank you.</font><br><br>" & body2
      response.write "<br><hr><br>To contact us:<br>Call: ---phone number nixed---<br>Fax: ---fax number nixed---<br>Email: <a href=mailto:---address nixed--->---address nixed---</a>"
     
    Set Mailer = nothing 
    end if
    end if
    %>
    Some things were clipped out but the important bits are there.
    Last edited by FreeFrag; Dec 7, 2006 at 12:25. Reason: Line breaks got clipped out making more illegible.

  4. #4
    SitePoint Wizard
    Join Date
    Nov 2004
    Location
    Nelson BC
    Posts
    2,310
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    At a quick glance, it looks fine.

    I'd check the form that leads to this page, see if it has any onsubmit code and go from there.


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
  •