Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

ASP.NET Forum


You are currently viewing our ASP.NET Forum as a guest. Please register to participate.
Login



Closed Thread
Sending a dynamic form to a mail address
Old 07-08-2009, 12:45 PM Sending a dynamic form to a mail address
Junior Talker

Posts: 1
Trades: 0
Hi there,

I explain the context. I wrote a dynamic html form (with a button to add fields) because our CMS (Episerver) is too limited. Then I found an ASP function (on the web cause I have no knowkedge in ASP as a simple Intranet editor) to send data to a mail address. The sending is fine but I don't know how to put the values of the generated fields in the body since I do not know how many fields would be filled (can I use a variable?).

Here are my asp function and my form fields below. Thanks in advance for any provided help!

ASP Function:
Code:
 <%

If Request.Form("btnSubmit") <> "" Then

  Dim Message
  Message = 
  Const cdoSendUsingPort = 2

  Dim oConfiguration

  Dim oMessage

  Dim oFields

  Set oMessage = CreateObject("CDO.Message")

  Set oConfiguration = CreateObject("CDO.Configuration")



  Set oFields = oConfiguration.Fields

  ' Set the CDOSYS configuration fields to use port

  ' 25 on the SMTP server.

  With oFields

  .Item("http://schemas.microsoft.com/cdo/configuration/sendusing") _

      = cdoSendUsingPort

  .Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") _

      = "mailhost.XXX.net"

  .Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") _

      = 10

  .Update

  End With



  ' Apply the settings to the message.

  With oMessage

    Set .Configuration = oConfiguration

    .To = "XX.XX@XX.com"

    .Bcc = ""

    .From = request.form("txtName")

    .Subject = request.form("txtName") & " requests a publication"

    .HTMLBody = Message

    .Send

  End With



  ' Clean up variables.

  Set oMessage = Nothing

  Set oConfiguration = Nothing

  Set oFields = Nothing



  Response.Redirect("XXX")

End If

%>
Form fields:
Code:
<!--
var i=1;
var input_add;
function create_champ(){
var newDiv = input_add.parentNode.insertBefore( document.createElement('div'), input_add );
newDiv.id = 'champs_'+i;
newDiv.innerHTML = '<table><tbody><tr><td>Title</td><td colspan="5"><input name="title_'+i+'" id="ti_'+i+'" size="40" type="text"/></td></tr><tr><td>Author</td><td colspan="5"><input name="author_'+i+'" id="au_'+i+'" size="30" type="text"/></td></tr><tr><td>Journal</td><td colspan="5"><input name="journal_'+i+'" id="so_'+i+'" size="30" type="text"/></td></tr><tr><td style="width: 65px;">Year</td><td style="width: 65px;"><input name="year_'+i+'" id="ye_'+i+'" size="4"type="text"/></td><td style="width: 65px;">Volume</td><td style="width: 65px;"><input name="volume_'+i+'" id="vol_'+i+'" size="4"type="text"/></td><td style="width: 60px;">Pages</td><td style="width: 65px;"><input name="pages_'+i+'" id="pa_'+i+'" size="4"type="text"/></td></tr></tbody></table><br>';
if(i>1) document.getElementById('input_sup').style.display = 'inline';
if(i>100) input_add.style.display = 'none';
i++;
}
Kxking is offline
View Public Profile
 
 
Register now for full access!
Old 07-10-2009, 05:42 PM Re: Sending a dynamic form to a mail address
kline11's Avatar
SearchBliss Web Tools

Posts: 1,719
Name: John
Location: USA
Trades: 0
You can add a function that will submit the form field information regardless of the name and value like this:

Code:
 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
So before the email is sent, the email body = name
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
kline11 is offline
View Public Profile
 
Closed Thread     « Reply to Sending a dynamic form to a mail address
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.17559 seconds with 12 queries