select not working properly

Hi Guys,

I have created a form where a user can select from a drop down list of
names. Based on the selection, a value is passed and appropriate email
is looked up.

Then, I call actionmailer to deliver the email.

Problem is that it seems that (from log file) rhtml file is passing
correct value to sendmail_qualitylead action, however, toEmail in the
action is either not getting set or not getting passed appropriately
(sql command seems to be executed as shown in log file).

.rhtml file ->
  <%=form_tag :controller=>"xyz", :action=>"sendmail_qualitylead"%>
  <table width="100%" border="0" cellspacing="1" cellpadding="3">
    <tr>
      <td width="29%" bgcolor="#EAF4F8">Name :</td>
      <td width="71%" bgcolor="#EAF4F8">
      <%=select(:lead, :contactID, @DropDown)%>
      </td>
    </tr>
......

xyz_controller ->
  def sendmail_qualitylead
    body=params[:lead]
    toEmail = Contact.find_by_sql(["select email from contacts where
id=?",body["contactID"]])
    Notifier.deliver_quality_lead_for_flying_club(body, toEmail)
    redirect_to :action => "dosearch"
  end

Notifier.rb ->
def quality_lead_for_flying_club(body, toEmail)
    @subject = 'Quality Lead'
    @body = body
    @recipients = toEmail
    @cc = body["senderEmail"]
    @from = "supp <support@johndoe.com>"
    @sent_on = Time.now
    @headers = {}
    content_type("text/html")
  end

I have spent almost a day stuck at this point :frowning: and I will really
appreciate any help.

Thanks

Rajat

Hi Guys,

I have created a form where a user can select from a drop down list of
names. Based on the selection, a value is passed and appropriate email
is looked up.

Then, I call actionmailer to deliver the email.

Problem is that it seems that (from log file) rhtml file is passing
correct value to sendmail_qualitylead action, however, toEmail in the
action is either not getting set or not getting passed appropriately
(sql command seems to be executed as shown in log file).

.rhtml file ->
  <%=form_tag :controller=>"xyz", :action=>"sendmail_qualitylead"%>
  <table width="100%" border="0" cellspacing="1" cellpadding="3">
    <tr>
     <td width="29%" bgcolor="#EAF4F8">Name :</td>
     <td width="71%" bgcolor="#EAF4F8">
     <%=select(:lead, :contactID, @DropDown)%>
     </td>
    </tr>
......

xyz_controller ->
def sendmail_qualitylead
   body=params[:lead]
   toEmail = Contact.find_by_sql(["select email from contacts where
id=?",body["contactID"]])

to_Email will be an instance of Contact here, but it looks like you
are expecting it to be the email address itself.
Try passting toEmail.email to deliver_quality_lead_for_flying_club

Fred