Need help in cfm forms for mailing multiple email addresses

Discussion in 'Programming' started by ccomm, Jul 26, 2009.

  1. #1
    hi, I'm pretty new to coldfusion. But since my server only supports this and nothing else i can only learn my way through this.

    I need a online enquiry form where there's different subjects user can select from drop down menu pertaining to enquiry like: Product Enquiry, General Enquiry and Sales Enquiry.

    whichever the user select will have the form submitted sent the results to different email addresses. Eg. if i select product enquiry and enter my details in the form, press submit, I will be receiving the form results at email1@test.com. And if i select sales enquiry.. form results will be sent to email2@test.com.

    how do i go about doing it? Really need help on this.. i've been searching for tips online but no tutorials available.. :(
     
    ccomm, Jul 26, 2009 IP
  2. gavy

    gavy Peon

    Messages:
    50
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Okay!

    Tell me have you hardcoded the values in the selct form as:

    <select name="a">
    <option value="products">productsenquiry</option>
    <option value="sales">salesenquiry</option>

    </select>

    Now in you action perform somthing like this:

    <cfif form.a IS 'Products'>
    <cfset form.useemail = "email@test.com">
    <cfelseif form.a IS 'sales'>
    <cfset form.useemail = "email2@test.com">
    <cfelse>
    <cfset form.useemail = "anyotherquery@test.com">
    </cfif>
     
    gavy, Aug 1, 2009 IP
  3. ccomm

    ccomm Peon

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    hi gavy!

    ok im not sure if this is what u're looking for..

    Currently in my basic form the select section is

    <FORM action="http://www.test.com/request.cfm" method="POST" name="inforequest"

    <select name="recipient" class="small">
    <option value="Please Select" selected="selected">Please Select</option>
    <option value="General">General Enquiries</option>
    <option value="Product">Product</option>
    <option value="Sales">Sales</option>
    <option value="Sample">Sample Request</option>
    <option value="Technical">Technical Support</option>
    </select>

    and my .cfm has this:

    p><cfmail to="request@test.com" from="Website Form <request@test.com>" subject="Website Information Request">
     
    ccomm, Aug 2, 2009 IP
  4. gavy

    gavy Peon

    Messages:
    50
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    here it is what i have understood:

    <FORM action="http://www.test.com/request.cfm" method="POST" name="inforequest"

    <select name="recipient" class="small">
    <option value="Please Select" selected="selected">Please Select</option>
    <option value="General">General Enquiries</option>
    <option value="Product">Product</option>
    <option value="Sales">Sales</option>
    <option value="Sample">Sample Request</option>
    <option value="Technical">Technical Support</option>
    </select>

    in your action page:

    <cfif form.recipient IS 'Product'>
    <cfset form.useemail = "Product@test.com">
    <cfelseif form.recipient IS 'Sales'>
    <cfset form.useemail = "Sales@test.com">
    <cfelse>
    <cfset form.useemail = "anyotherquery@test.com">
    </cfif>

    <cfmail to="request@test.com" from="Website Form <#form.useemail#>" subject="Website Information Request">

    This will trigger the email from the rspective email address

    let me know if u stuck again
     
    gavy, Aug 4, 2009 IP
  5. ccomm

    ccomm Peon

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    thanks gavy!

    at first it couldn't work.. then i figure out and amend to
    <cfmail to="#form.useemail#" from="Website Form <#form.useemail#>" subject="Website Information Request">

    then it's ok. Thanks a lot!!!!!!!!!!!!!!!!!!!! :D
     
    ccomm, Aug 5, 2009 IP